将时间戳变量纳入PostgreSQL Update语句
我有以下代码段。它应该在我的PostgreSQL数据库中更新一排数据。我遇到的问题是,按照典型的时间戳格式(这给出语法错误),时间戳在日期和时间之间具有空间。如果我不想合并变量变量,我知道我将能够将其包装在“”中并将其称为“一天”。如何使用合并变量的括号方法完成?
cursor.execute("UPDATE {} SET timestamp = {}, ememctotal = {}, busload = {}, dgload = {}, temp = {}, cvr = {} WHERE (year = {} AND month = {});".format(histTable, mTimestamp, mPeak, mBusLoad, mdgLoad, mTemp, mstatus, histYear, histMonth))
print ("Historical Peak Data update complete")
I have the following snippet of code. It's supposed to update a row of data in my postgresql database. The issue I am running into is that the timestamp has a space between the date and time, following a typical timestamp format (which is giving a syntax error). If I weren't trying to incorporate a changing variable, I understand that I'd be able to just wrap it in " " and call it a day. How is it done using the bracket method of incorporating variables?
cursor.execute("UPDATE {} SET timestamp = {}, ememctotal = {}, busload = {}, dgload = {}, temp = {}, cvr = {} WHERE (year = {} AND month = {});".format(histTable, mTimestamp, mPeak, mBusLoad, mdgLoad, mTemp, mstatus, histYear, histMonth))
print ("Historical Peak Data update complete")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论