簡體   English   中英

python 2.4.3 sqlite executemany語法

[英]python 2.4.3 sqlite executemany syntax

我被困在使用python 2.4.3和該發行版發布的sqlite模塊中。

如何在這種環境中運行executemany命令? 更現代的語法似乎有問題。

import sqlite as sql
conn = sql.connect('test.db')
c = conn.cursor()
c.execute('''create table test(item text)''')
list = ['apple', 'orange', 'banana']

c.executemany('''insert into test values(?)''', list)

我猜Python 2.4.3很老了,我找不到任何文檔,也沒有與executemany函數關聯的關聯文檔字符串。

我感謝您的幫助。

您應該使用%s而不是?

import sqlite as sql
conn = sql.connect('test.db')
c = conn.cursor()
c.execute('''create table test(item text)''')
list = ['apple', 'orange', 'banana']
c.executemany('''insert into test values(%s)''', list)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM