更新1: 其他線路工作(感謝您的幫助!)。現在,我試圖運行以下命令,這不會工作要麼,我得到13行錯誤:sqlite3.OperationalError:近「」:語法錯誤sqlite3.OperationalError:near「,」:語法錯誤
的代碼如下:
cur.execute("CREATE TABLE Progress(Id INTEGER PRIMARY, Username STRING, Topic1 STRING, Topic2 STRING, Topic3 STRING, Topic4 STRING, 1Result STRING, 2Result STRING, 3Result STRING, 4Result STRING, TResut STRING, TCorrect INTEGER, TWrong INTEGER, TAttempted INTEGER)")
cur.exectue("INSERT INTO Progress VALUES(1, 'Admin', 'Algebra', 'Number', 'Shape, Space and Measures', 'Handling Data', '100%', '100%', '100%', '100%', '100%', '10', '0', '10')")
我創建瞭如下圖所示,在嘗試輸入一些數據表中的SQL表,但我不斷收到以下錯誤:sqlite3.OperationalError:接近「1」:語法錯誤
con = lite.connect('Records.db')
with con:
cur = con.cursor()
cur.execute("CREATE TABLE Questions(Id INTEGER PRIMARY KEY, Question STRING, Answer STRING, Mark INTEGER, Topic STRING, Incorrect STRING, QType STRING)")
cur.execute("INSERT INTO Questions(1, 'What is 2/3 of 6?', '4', '1', 'Fractions', 'None', 'Numerical')")
下面有幾個正確答案。但是請注意,建議使用此命令的「完整」版本INSERT INTO Questions(ID,Question,Answer,Mark,Topic,Incorrect,QType)VALUES(1,'What is 2/3 of 6?', '4','1','分數','無','數值'),因爲它對後來對數據庫結構的更改更安全。 –
Ohhhh ....我忘了VALUES –