gpt4 book ai didi

python - 为什么这个sql脚本不执行?

转载 作者:太空宇宙 更新时间:2023-11-03 19:28:00 24 4
gpt4 key购买 nike

嗨,我有以下 python:

c = conn.cursor()

#get the account id for the specific user

actidSQL = "select id from accounts where user_id = (select id from auth_user where username = '%s');" % user
c.execute(actidSQL)
actid = c.fetchone()[0]
print actid

#fill the latencies table - currently not firing, not sure why?
latencies_sql = "insert into latencies(account, replier, sender, replyemail, origemail, replydate, origdate) select m1.account, c1.id as replier, c2.id as sender, m1.id as replyemail, m2.id as origemail, m1.date as replydate, m2.date as origdate from contacts c1, contacts c2, emails m1, emails m2 where m1.id > m2.id and m1.reply = m2.mid and m1.reply is not null and c1.id = m1.fr and c2.id = m2.fr and m1.account = %s and m1.account = m2.account;" % (actid)
print latencies_sql
c.execute(latencies_sql)

第一个 sql 执行,但第二个 sql 不执行。有什么原因吗?

最佳答案

“第一个 sql 执行但第二个 sql 不执行。”是什么意思?你得到一个错误吗?或者数据库中没有数据?我假设数据库中没有数据并且您使用的是MySQL。这是因为您没有提交更改。脚本末尾的 conn.commit() 应该会有所帮助。

关于python - 为什么这个sql脚本不执行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7357995/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com