import sqlite3 c = sqlite3.connect('history.db') print("messages:", [d[1] for d in c.execute("PRAGMA table_info(messages)").fetchall()]) print("chat_history:", [d[1] for d in c.execute("PRAGMA table_info(chat_history)").fetchall()])