我有一个 SQLite3 格式的数据库文件 .db,我试图打开它以查看其中的数据。下面是我使用 python 编码的尝试。
import sqlite3
# Create a SQL connection to our SQLite database
con = sqlite3.connect(dbfile)
cur = con.cursor()
# The result of a "cursor.execute" can be iterated over by row
for row in cur.execute("SELECT * FROM "):
print(row)
# Be sure to close the connection
con.close()
Run Code Online (Sandbox Code Playgroud)
对于这一行("SELECT * FROM "),我知道您必须在“FROM”一词之后放入表格的标题,但是,由于我什至无法首先打开文件,因此我不知道该放置什么标题。因此,我该如何编码才能打开数据库文件以读取其内容?