Well i guess something is not right with the mariadb connector...
I have a table row that looks like this:
| id | title | category | date_posted | date_due | content | file | user_id |
|---|---|---|---|---|---|---|---|
| 6 | test 7 | 10 | 2021-04-01 21:50:21 | content 7 | strawsf9cdaf.txt | 16 |
The problem is that i have a DATETIME field that is NULL (the date_due date is not mandatory in my app)
It seems that after passing values to the execute() method, the fetchall() method parses returned data differently.
First case works great Second returns the "ValueError: year 0 is out of range"
id=("6",)
statement1 = "select * from posts where id = 6"
statement2 = "select * from posts where id = ?"
db.cursor.execute(statement1)
result = db.cursor.fetchall()
for x in result:
print(x)
db.cursor.execute(statement2, id)
result = db.cursor.fetchall()
for x in result:
print(x)
I tried to list() the connector - same result
I tried to change values and table column attributes - same result
I though its a problem of versions so i updated to latest python, mariadb server and python connector (on ubuntu 20.04)- same result
The result:
6, 'test 7', 10, datetime.datetime(2021, 4, 1, 21, 50, 21), None, 'content 7', 'strawsf9cdaf.txt', 16)
ValueError: year 0 is out of range
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/project dir/main_test3.py", line 38, in <module>
result = db.cursor.fetchall()
SystemError: <method 'fetchall' of 'mariadb.connection.cursor' objects> returned a result with an error set
Process finished with exit code 1
Any help will be greatly appreciated