python mysql date error“raise errorclass,errorvalue”

eh57zj3b  于 2021-06-21  发布在  Mysql
关注(0)|答案(0)|浏览(190)

我正在尝试使用pythonmysql在两个日期之间从mysql数据库中获取记录,但是遇到了raiseerrorclass,errorvalue
下面是我的代码,请让我知道我哪里做错了

request_date = parse(from_date) #2018-06-01 00:00:00
parsed_from_date = request_date.strftime("%Y-%m-%d %X")

request_date1 = parse(to_date) #2018-06-04 00:00:00
parsed_to_date = request_date1.strftime("%Y-%m-%d %X")
query_string = 'SELECT * FROM test_inof where test_image = %s and  test_readydate_time>=%s and test_readydate_time<=%s'
if(area):
    query_string = query_string + " and area = ' " +  area +  " ' "
if(team):
    query_string = query_string + " and team =' " + team + " ' " 
t = testInfo.objects.raw(query_string,[image,str(parsed_from_date), str(parsed_to_date)])

错误是:

File "c:\users\dasarr\appdata\local\temp\easy_install-flprbl\MySQL_python-1.2.5-py2.7-win32.egg.tmp\MySQLdb\connections.py", line 36, in defaulterrorhandler raise errorclass, errorvalue
ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'test_inof where image = 'test' and  test_readydate_time>' at line 1")

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题