私はMariaDBサーバ(V 10.1.12)に接続し、いくつかのクエリの結果をファイルに保存するpythonスクリプトを書いています。次のクエリを送信するとき しかし、:PythonコードからのMariaDBクエリ
cursor.execute(sql)
続い
sql = 'SELECT * FROM Monitor_Run_Tracking WHERE Entry IN (SELECT MAX(Entry) ' \
'FROM Monitor_Run_Tracking WHERE Run in ({0}) ' \
"AND WhenEntered<'{1}' GROUP BY Run)".format(runstr, quality_date)
、私は次のエラーを取得する:
File "build/bdist.linux-x86_64/egg/MySQLdb/cursors.py", line 174, in execute
File "build/bdist.linux-x86_64/egg/MySQLdb/connections.py", line 36, in defaulterrorhandler _mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') AND WhenEntered<'2020-01-01' GROUP BY Run)' at line 1")
は、誰かがミスがあるものを私に説明してもらえますか?
ありがとうございます!
私たちはあなたの 'runstr' – KRONWALLED
runstrは、カンマで区切られた数字の文字列である必要があると思う。「runstr = 60092,60093,60094」 – id5h