由于某种原因,我找不到与 sqlite 的交互式 shell 命令等效的方法:
.tables
.dump
使用 Python sqlite3 API。
有类似的吗?
最佳答案
在 Python 中:
con = sqlite3.connect('database.db')
cursor = con.cursor()
cursor.execute("SELECT name FROM sqlite_master WHERE type='table';")
print(cursor.fetchall())
当心我的另一个 answer .使用 pandas 有一种更快的方法。
关于python - 使用 Python sqlite3 API 的表、数据库模式、转储等列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/305378/