mysql大佬进,语法问题

查看 53|回复 4
作者:mishi   
   
sql = "update table1 set ppid='{}', updatetime='{}' where name='{}'".format(ppid,NOW(),row[1])
老是提示  NameError: name 'NOW' is not defined
啥情况啊  
已经 import time 了啊 updatetime 字段设为 datetime类型了

大佬, 设为, 字段

waiwaiwq   
import time
current_time = time.strftime('%Y-%m-%d %H:%M:%S')  # 格式化当前时间
sql = "update table1 set ppid='{}', updatetime='{}' where name='{}'".format(ppid, current_time, row[1])
[ol]import time
current_time = time.strftime('%Y-%m-%d %H:%M:%S')  # 格式化当前时间
sql = "update table1 set ppid='{}', updatetime='{}' where name='{}'".format(ppid, current_time, row[1])[/ol]复制代码
mishi
OP
  

waiwaiwq 发表于 2023-11-26 07:37
import time
current_time = time.strftime('%Y-%m-%d %H:%M:%S')  # 格式化当前时间

兄弟是高手   感谢!
Unit2411   
没有NOW这个函数,你先格式化一下当前日期就好
Libs   
now( )是mysql中的函数,直接拼字符串里面
您需要登录后才可以回帖 登录 | 立即注册

返回顶部