[英]AWS RDS MySQL Database not taking INSERT statements from pymysql
So basically what the title says, I can connect to it and make the exact same queries with SQLelectron from my computer (where I am running the script).所以基本上正如标题所说,我可以连接到它并从我的计算机(我正在运行脚本)使用 SQLelectron 进行完全相同的查询。 It doesn't give me errors either, and I can make SELECT queries with sql electron from the same script.它也没有给我错误,我可以使用 sql electron 从同一个脚本进行 SELECT 查询。 What's more is my id column, (on which I have AUTO_Increment enabled) seems to jump to later values when I make the same insert statement from sql electron as if I actually inserted the row, but it does not actually insert.更重要的是,当我从 sql electron 发出相同的插入语句时,我的 id 列(我在其上启用了 AUTO_Increment)似乎跳转到后面的值,就好像我实际插入了行一样,但它实际上并没有插入。 Here is the code snippet:这是代码片段:
sql = ['INSERT INTO liftdb.lifts',
'(Date, lift, weight)',
'VALUES',
'(%s, %s, %s)']
cur.execute(' '.join(sql), (date, event['Lift'], event['Weight']))
Again, no errors or indication something went wrong.同样,没有错误或指示出现问题。
If your code is acting like theres been a change (by increasing the auto-increment) yet you cant notice any changes, thats a strong indication that you may have forgotten to commit the changes to the database.如果您的代码表现得好像发生了变化(通过增加自动增量)但您没有注意到任何变化,这强烈表明您可能忘记将更改提交到数据库。 (something like cur.commit()
on the next line down. Assuming you have commited the changes, it could also be that whatever software youre using to check if the database has changed may need to be refreshed in-order to show the changes. (类似于下一行的cur.commit()
。假设您已提交更改,也可能是您用于检查数据库是否已更改的任何软件都可能需要刷新以显示更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.