2017-03-03 22 views
0

次のフィールドで構成された 'outfield'というテーブルにINSERTを実行しようとしています:outfieldplayerID(自動インクリメントとPK)以下のように、姓、Forename、チーム、ゲームプレイ、ゲーム分が再生、開始、目標、アシスト、ショット、ショットの目標に、イエローカード、レッドカード"1064(42000):SQL構文にエラーがあります。"

は私のコードは次のとおりです。

import mysql.connector 

conn = mysql.connector.connect(user='root',password ="password5",host='localhost',database='performance') 
query = "INSERT INTO outfield ('Surname', 'Forename', 'Team', 'Games Played', 'Games Started', 'Minutes Played', 'Goals', 'Assists', 'Shots', 'Shots on goal', 'Yellow cards', 'Red cards') values('a','b','c','1','1','1','1','1','1','1','1','1')" 

cursor = conn.cursor() 
cursor.execute(query) 
conn.commit() 
rows = cursor.fetchall() 
cursor.close() 
conn.close() 

私はINSERT行に構文エラーが発生しました。どこが間違っていますか?列名で``代わりに単一引用符''

答えて

0

使用バッククォート:

insert into outfield (`Surname`, `Forename`, `Team`, `Games Played`, `Games Started`, `Minutes Played`, `Goals`, `Assists`, `Shots`, `Shots on goal`, `Yellow cards`, `Red cards`) 
values ('a', 'b', 'c', '1', '1', '1', '1', '1', '1', '1', '1', '1') 

また、それはあなたがすべてでバッククォートを使用する必要はありませんように識別子を定義する方が良いでしょう。

+0

問題が解決しました。非常に感謝、ありがとう – hoops9682

関連する問題