Python 什么';MySQL语句中的错误是什么?
我使用pythonshell并执行一个'insert'sql,它显示为“SyntaxError:invalid syntax”,任何人都可以告诉我MySQL语句中的错误是什么?谢谢Python 什么';MySQL语句中的错误是什么?,python,mysql,Python,Mysql,我使用pythonshell并执行一个'insert'sql,它显示为“SyntaxError:invalid syntax”,任何人都可以告诉我MySQL语句中的错误是什么?谢谢 cursor.execute("insert into monitor_task (job_id, task_id, host, port, active, last_attempt_time, last_status last_message, last_success_time, last_metrics, la
cursor.execute("insert into monitor_task (job_id, task_id, host, port, active, last_attempt_time, last_status last_message, last_success_time, last_metrics, last_metrics_raw) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", [1L, 0, 'hh-hadoop-srv-ct01.bj', 11101, True, datetime.datetime(1970, 1, 1, 0, 0, tzinfo=<UTC>), 2, '', datetime.datetime(1970, 1, 1, 0, 0, tzinfo=<UTC>), '', ''])
File "<console>", line 1
cursor.execute("insert into monitor_task (job_id, task_id, host, port, active, last_attempt_time, last_status last_message, last_success_time, last_metrics, last_metrics_raw) values (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)", [1L, 0, 'hh-hadoop-srv-ct01.bj', 11101, True, datetime.datetime(1970, 1, 1, 0, 0, tzinfo=<UTC>), 2, '', datetime.datetime(1970, 1, 1, 0, 0, tzinfo=<UTC>), '', ''])
^
SyntaxError: invalid syntax
SyntaxError
是一个Python错误。语法错误出现在datetime
对象创建中:
datetime.datetime(1970, 1, 1, 0, 0, tzinfo=<UTC>)
datetime.datetime(1970,1,1,0,0,tzinfo=)
tzinfo=
是一个Python语法错误:
$ python
Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> datetime.datetime(1970, 1, 1, 0, 0, tzinfo=<UTC>)
File "<stdin>", line 1
datetime.datetime(1970, 1, 1, 0, 0, tzinfo=<UTC>)
^
SyntaxError: invalid syntax
$python
Python 2.7.3(默认,2014年3月13日,11:03:55)
[GCC 4.7.2]关于linux2
有关详细信息,请键入“帮助”、“版权”、“信用证”或“许可证”。
>>>导入日期时间
>>>datetime.datetime(1970,1,1,0,0,tzinfo=)
文件“”,第1行
datetime.datetime(1970,1,1,0,0,tzinfo=)
^
SyntaxError:无效语法
如何提供有效的
tzinfo
参数。箭头指向错误所在。您不能说tzinfo=
,您需要一个实际的tzinfo对象。last\u status last\u message
语法错误。一定有个逗号。ielast_status,last_message
@suhail是的,我已经修复了语法错误。非常感谢。
$ python
Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> datetime.datetime(1970, 1, 1, 0, 0, tzinfo=<UTC>)
File "<stdin>", line 1
datetime.datetime(1970, 1, 1, 0, 0, tzinfo=<UTC>)
^
SyntaxError: invalid syntax