python - sqlite查询表名 列名

wstong2052 / 2023-06-08 / 原文

最近在看到一个之前做的sqlite数据库时发现忘了table名叫什么了,所以找了找发现可以直接用python查询,记录一下

import sqlite3
conn = sqlite3.connect('test.db')
cur = conn.cursor()
sql = "select * from sqlite_master where type='table'"
cur.execute(sql)
print(cur.fetchall())