0
後のクエリでsqliteクエリの結果を使用しようとしています。以下のコードでは、exam [1]が文字列で、 'endtime'が正しく出力されることに注意してください。しかし、私はdb.executeステートメントにそれを渡すことはできないようです。問題をもっと混乱させるために、Pythonのコマンドライン(endtimeをstringに設定し、db.execute文を呼び出す)から同じことをすれば、期待どおりに動作します。私が何が欠けているかについてのアイデア。sqliteにdatetimeを渡す方法
exam_listは、2つのdatetime文字列と1つのuuidで構成されています。私は同じ結果を持って(kiosk、exam [1]、exam [1]、)の値を渡そうとしました。
for exam in exam_list:
print "%s\t%s\n%s\t%s\n%s\t%s\n" % (exam[0],type(exam[0]),exam[1],type(exam[1]),exam[2],type(exam[2]),)
endtime = exam[1]
print "Endtime is %s" % (endtime)
db.execute("""select sessionid, examtype, email from schedule where stationid = ? and iestart < ? and ieend > ? and status = 'Pending' """, (kiosk, endtime, endtime,))
は、私は、私はそれを考え出したと思う
2016-12-16 14:45:00 <type 'str'>
2016-12-16 19:30:00 <type 'str'>
48f7a832-cf8a-47c2-b3b0-b279fc23f932 <type 'str'>
Endtime is 2016-12-16 19:30:00
Traceback (most recent call last):
File "checkschedule.py", line 62, in <module>
check_overlap(kiosk)
File "checkschedule.py", line 40, in check_overlap
db.execute("""select sessionid, examtype, email from schedule where stationid = ? and iestart < ? and ieend > ? and status = 'Pending' """, (kiosk, endtime, endtime,))
sqlite3.InterfaceError: Error binding parameter 0 - probably unsupported type.