我正在使用Python通过SQLite3创建一个表,我被告知该表已在解释器中创建,但是当在cmd中查看该表时,没有这样的表。这是我的代码:
import sqlite3 as db
conn = db.connect('test.db')
cursor = conn.cursor()
cursor.execute("create table films(title text, year text, director text)")
print("tables added")
在解释器中我得到:
>>> ================================ RESTART ================================
>>>
tables added
但是当我在 cmd 中通过 SQLite 查看数据库时,我被告知:
Error: no such table: films
最佳答案
确保在同一目录中运行脚本和解释器。否则它们引用两个不同的数据库文件。
关于python - 使用Python和SQLite创建表,没有这样的表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21967787/