2017-12-18 14 views

답변

2

아마도 문자열을으로 삽입하려고합니다. datetime 개체로 매개 변수화하고 let the database driver handle the type conversion automatically :

from datetime import datetime 

date_string = "Sun, 17 Dec 2017 14:26:07 GMT" 

dt = datetime.strptime(date_string, "%a, %d %b %Y %H:%M:%S %Z") 

cursor.execute('INSERT INTO some_table (somecol) VALUES (%s)', (dt,))