尝试将数据从 Python(3.9.1) 编译到 SQLite3 时出现错误。
import sqlite3
conn = sqlite3.connect('newdB.db')
#Creates the table 'tbl_newdb' with an incrementing ID, and 'db_type' columns.
with conn:
cur = conn.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS tbl_newdb( \
ID INTEGER PRIMARY KEY AUTOINCREMENT, \
db_type TEXT)")
conn.commit()
conn.close()
conn = sqlite3.connect('newdB.db')
#Our list of data we will be grabbing from to fill the tables.
with conn:
cur = conn.cursor()
fileList = "information.docx","Hello.txt","myImage.png","myMovie.mpg","World.txt","data.pdf","myPhoto.jpg"
cur.execute("INSERT INTO tbl_newdb (db_type) VALUES (?)",(fileList,))
conn.commit()
conn.close()
Run Code Online (Sandbox Code Playgroud)
这是我从 IDLE shell 收到的错误消息:
line …Run Code Online (Sandbox Code Playgroud)