import sqlite3 c = sqlite3.connect('/home/hmo/MoFin/data/mofin.db') sql = c.execute("SELECT sql FROM sqlite_master WHERE name='price_events'").fetchone()[0] print(sql) print() for r in c.execute("PRAGMA foreign_key_list(price_events)"): print(r)