2016-05-26 13 views
0

私はPythonスクリプトに値を挿入しようとしていますが、エラーは出ませんが、SQLファイルには表示されません。あなたはmsotおそらくDBへの変更をコミットするために忘れている任意のトレースバックエラーが発生してアレント場合Sqlの挿入文に何も表示されません

は、ここでは、コード

#Connect the db to this python script 
top10_connection = connect(database = 'top_ten.db') 

#Get a cursor for the database which allows you to make 
#and execute sql queries in this script 
top_ten_db = top10_connection.cursor() 

top_ten_db.execute("INSERT INTO Top_Ten (Rank) VALUES(1)") 

top10_connection.close() 
+1

これはあなたの全体のコードで、あなたのコード – WildCard

答えて

1

です。

あなたが接続を閉じる前にtop10_connection.commit()を追加します。

top10_connection = connect(database = 'top_ten.db') 

#Get a cursor for the database which allows you to make 
#and execute sql queries in this script 

top_ten_db = top10_connection.cursor() 

top_ten_db.execute("INSERT INTO Top_Ten (Rank) VALUES(1)") 

top10_connection.commit() 

top10_connection.close() 
+0

のすべてはどうもありがとう提供してください、それが働きました –

関連する問題