Created
February 9, 2015 11:59
-
-
Save alxsimo/aca6e00e6d80a0a145ae to your computer and use it in GitHub Desktop.
[Python] Search in all SQLite database
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 sqlite3 | |
import os | |
filename = ... | |
with sqlite3.connect(filename) as conn: | |
conn.row_factory = sqlite3.Row | |
cursor = conn.cursor() | |
cursor.execute("SELECT name FROM sqlite_master WHERE type='table'") | |
for tablerow in cursor.fetchall(): | |
table = tablerow[0] | |
cursor.execute("SELECT * FROM {t}".format(t = table)) | |
for row in cursor: | |
for field in row.keys(): | |
print(table, field, row[field]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment