[英]How do I use the values in the tuple miltiple times when doing an execute in sqlite3
[英]How do I use execute, rather than execute script in SQLite3?
在下面的代碼中,scheduling.sql 正常執行,而 dummy.sql 沒有。 我沒有收到錯誤消息。 它似乎沒有做任何事情。 對於dummy.sql,我更喜歡使用execute,而不是executescript,所以我可以給它傳遞一些參數。 我在這里做錯了什么?
db = sqlite3.connect(':memory:')
cursor = db.cursor()
with open('scheduling.sql', 'r') as sql_file:
sql_script = sql_file.read()
cursor.executescript(sql_script)
with open('dummy.sql', 'r') as sql_file:
sql_script = sql_file.read()
fetch=cursor.fetchone()
while fetch:
cursor.execute(fetch)
fetch=cursor.fetchone()
它從不執行dummy.sql
。 什么是fetch
后fetch=cursor.fetchone()
執行? 猜測是假的。 fetch...
在execute....
之后出現execute....
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.