Skip to content

Instantly share code, notes, and snippets.

@sligodave
Created November 13, 2012 22:28
Show Gist options
  • Save sligodave/4068873 to your computer and use it in GitHub Desktop.
Save sligodave/4068873 to your computer and use it in GitHub Desktop.
import firebirdsql
conn = firebirdsql.connect(
dsn='localhost/3050:PATH_TO_DB.fdb',
user='sysdba',
password='masterkey'
)
cur = conn.cursor()
# Get all rows from a table
query = "select * from RECEIVED;"
# Get all tables
query = '''select rdb$relation_name
from rdb$relations
where rdb$view_blr is null
and (rdb$system_flag is null or rdb$system_flag = 0);'''
# Get all views
query = '''select rdb$relation_name
from rdb$relations
where rdb$view_blr is not null
and (rdb$system_flag is null or rdb$system_flag = 0);'''
# Get all columns
query = '''select f.rdb$relation_name, f.rdb$field_name
from rdb$relation_fields f
join rdb$relations r on f.rdb$relation_name = r.rdb$relation_name
and r.rdb$view_blr is null
and (r.rdb$system_flag is null or r.rdb$system_flag = 0)
order by 1, f.rdb$field_position;'''
cur.execute(query)
for c in cur.fetchall():
print c
conn.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment