Message219041
Observe the following code:
import MySQLdb, MySQLdb.cursors, datetime
""" ... mysqlCursor is a cursor object from a connection to database from the MySQLdb module ... """
mysqlCursor.execute("SELECT NOW()")
timeRow = mysqlCursor.fetchall()
currentDateTime = datetime.datetime.strptime(timeRow[0]["NOW()"], "%Y-%m-%d %H:%M:%S")
I get the following error:
TypeError: must be string, not datetime.datetime
HOWEVER, when I cast timeRow[0]["NOW()"] to a string like: str(timeRow[0]["NOW()"]) , it works fine.
For whatever reason the Python interpreter seems to interpret the string from the row of the MySQLdb cursor result as a datetime.datetime object. I have no explanation for this, besides it looking like a date time in the format of YYYY-mm-dd HH:MM:SS.
I have not tried this in Python 3.x, but the bug is in the latest compile of version 2.7.6 from the FTP distribution site. |
|
Date |
User |
Action |
Args |
2014-05-24 13:55:14 | brandon | set | recipients:
+ brandon |
2014-05-24 13:55:14 | brandon | set | messageid: <1400939714.27.0.921682878277.issue21570@psf.upfronthosting.co.za> |
2014-05-24 13:55:14 | brandon | link | issue21570 messages |
2014-05-24 13:55:12 | brandon | create | |
|