MySQL を使用して、Python でクエリを作成し、ローカル データベースに行を入力していました。私の変数product
は 33 個の値を保持するタプルです。roottable
これらの値をすべて、 (dbForge で作成した)というテーブルにリストされている適切な列に追加したいと考えています。行でエラーが発生しましたcon.execute()
:
TypeError: not all arguments converted during string formatting
私が間違っているのかわかりません。SQlite と同じ構文を適用しています。これが私のコードです:
connection = msql.connect(host = 'localhost', user = 'me', passwd = 'password', db = 'TESTDB')
with connection:
for product in list_product:
#Get a tuple of standardized informtaion to store in table
product = normalize_table_entry(product)
con = connection.cursor()
con.execute('INSERT INTO roottable VALUES (?,?,?,?,?,?,?,?,?,\
?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', product)
#connection.commit()