Created
January 8, 2015 17:13
-
-
Save chapinb/68a09b9bf4c5c7ccf197 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
def get_sqlite_veiw_info(db_path): | |
""" | |
Read all SQLite table names | |
:param db_path: String path to database | |
:return: List of table names | |
""" | |
# TODO: Add ability to filter responsive table names | |
con = sqlite3.connect(db_path) | |
cur = con.cursor() | |
cur.execute('Select name, sql from sqlite_master where type = \'view\';') | |
# convert tuples to lists | |
tmp = cur.fetchall() | |
tmp2 = [] | |
tmp3 = dict() | |
for i in tmp: | |
for x in i: | |
tmp3['name'] = x[0] | |
tmp3['sql'] = x[1] | |
tmp2.append(tmp3) | |
return tmp2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment