0
我得到了一些代碼,但沒有真正得到它的工作INSERT Python列表到MySQL數據庫
listdata = [1, 2]
listdata1.insert(1, raw_input("Enter first thing into DB: ")
listdata2.insert(2, raw_input("Enter second thing into DB: ")
然後,我讓DB,然後
cursor.execute("INSERT INTO testdb (TABLE, TABLE) VALUES (%s, %s)", (listdata1, listdata2
這給了我: NameError:名字「listdata1 '未定義
這樣插入甚至可能嗎?或者我怎麼才能使它工作?
您正試圖將條目插入到列表listdata1和listdata2中,這些條目不存在。你爲什麼使用這個特定的數據結構而不是變量? – abought 2012-07-07 13:22:41