遇到了一个问题,起初看起来很简单。
我想这样做(为了简洁起见,查询已被简化,它实际上更长更复杂):
query = ("""INSERT INTO %s " % cfg['mysql.table']
"('hostname', 'timestamp', 'metric', 'average', 'peakhigh', 'peaklow', 'gsamp', 'zsamp', 'nsamp')"""
"VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s )"
)
那么,如何将STR_TO_DATE合并到时间戳字段的此查询中呢?
感谢您的任何帮助。
将字符串放在三引号内:
query = ("""INSERT INTO %s " % cfg['mysql.table']
"('hostname', 'timestamp', 'metric', 'average', 'peakhigh', 'peaklow', 'gsamp', 'zsamp', 'nsamp')"
"VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s )"""
)