0

こんにちは私はスクレイプとパイプラインの作成に取り組んでおり、その中でデータをmysqlデータベースに書き込む必要があるクエリがありました

tx.execute("""INSERT INTO example_table (book_name,price)
                            VALUES (%s,%s)""",   
                                    (item['book_name'],
                                     item['price'],)

                            )

次のエラーが発生します以下の2つのエラー

(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 2")

(1241, 'Operand should contain 1 column(s)')

このクエリの何が問題なのかわかりませんが、データをデータベースに保存できません。

誰もがこれについての考えを持つことができますか?

4

2 に答える 2

1

%実行中に追加するのを忘れました

x.execute("""INSERT INTO example_table (book_name,price)
                            VALUES (%s,%s)""",%   
                                    (item['book_name'],
                                     item['price'])

                            )
于 2012-06-07T12:26:01.793 に答える
0

最後にカンマを追加して削除しました。以下は正しいステートメントです。どうぞお試しください。

x.execute("""INSERT INTO example_table (book_name,price)
                            VALUES (%s,%s,%s,%s,%s,%s)""",   
                                    (item['book_name'],
                                     item['price'])

                            )
于 2012-06-01T10:59:28.593 に答える