I'm trying to run a pymysql select statement, and use the datetime in my code. I was able to print the output and the query is correct, but I can't run dict commands on the variable I used to store the data. It keeps saying the type of the object is None, even though I declared it as an empty dict at the start of my function.
The output return as follows: {'last_date': datetime.datetime(2023, 4, 9, 13, 30)}
. How do I manipulate these numbers so I can build a datetime objetct in my script?
EDIT: my query is: "SELECT last_date from mysqldb.table_name ORDER BY last_date DESC LIMIT 1
"
last_date type in the database is datetime(3)
EDIT2: Here is the code:
last_date = {}
sqlQuery = "(...)"
cursorObject.execute(sqlQuery)
last_date = cursorObject.fetchone()
I'm having trouble to access the data inside last_date, when using dict functions it returns like: (...) is not a known member of "None"