Created
November 13, 2012 22:28
-
-
Save sligodave/4068873 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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