Skip to content

Instantly share code, notes, and snippets.

@alxsimo
Created February 9, 2015 11:59
Show Gist options
  • Save alxsimo/aca6e00e6d80a0a145ae to your computer and use it in GitHub Desktop.
Save alxsimo/aca6e00e6d80a0a145ae to your computer and use it in GitHub Desktop.
[Python] Search in all SQLite database
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