This date string is in RFC 2822 date format and can be parsed with email.utils.parsedate (which is part of the standard library):
In [428]: import email.utils as eu In [429]: eu.parsedate('Thu, 14 Mar 2013 13:33:07 -0400') Out[429]: (2013, 3, 14, 13, 33, 7, 0, 1, -1)
Once you have a datetime object, you can paste it into this form (without formatting) in MySQL:
date = eu.parsedate('Thu, 14 Mar 2013 13:33:07 -0400') self.cursor.execute("INSERT INTO table1 (`DATE`) VALUES (%s)",(date,))
Note. The second argument to cursor.execute must be a sequence. So use tuple (date,) instead of the datetime (date) object.
Also, no semicolons are needed in your SQL strings.
source share