我正在尝试更新数据库条目上的时间戳,当我使用它时,我似乎无法让 Update 语句工作
import apsw
from datetime import datetime
def updateTimestamp(primary, timestamp):
tableName = 'Images'
connection = apsw.Connection('Images')
cursor = connection.cursor()
sql = "UPDATE %s SET timestamp = %s WHERE id = %s" %(tableName, timestamp, primary)
print "ok so far"
cursor.execute(sql)
if connection:
connection.close()
currentTime = datetime.now()
#remove spaces from timestamp
currentTime = str(currentTime).replace(' ', '')
updateTimestamp(1, currentTime)
我正在使用 apsw 尝试更新字段,但它不起作用我收到错误消息
"apsw.SQLError: SQLError: near ":05": syntax error"
我的桌子看起来像:
sql = 'CREATE TABLE IF NOT EXISTS ' + tableName + '(id INTEGER PRIMARY KEY
AUTOINCREMENT, Name TEXT, Metadata TEXT, Mods TEXT, Certification TEXT,
Product TEXT, Email TEXT, notes TEXT, timestamp TEXT, ftpLink TEXT)'