You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With Sqlalchemy 2.0:
when defining a DateTime column in table model as: ..., default=datetime.datetime.utcnow)
I get the following error at query: File "/venv/lib/python3.8/site-packages/sqlalchemy/engine/result.py", line 521, in <listcomp> return [make_row(row) for row in rows] File "lib/sqlalchemy/cyextension/resultproxy.pyx", line 25, in sqlalchemy.cyextension.resultproxy.BaseRow.__init__ File "lib/sqlalchemy/cyextension/processors.pyx", line 34, in sqlalchemy.cyextension.processors.str_to_datetime ValueError: Invalid isoformat string: '2023-04-24 08:54:34.53687'
it seem to work with: datetime.datetime.utcnow()
But that datetime is then corresponding to table creation time and not row creation time.
Any suggestion what I can do about it?
The issue does not occur when using Sqlite3.
The text was updated successfully, but these errors were encountered:
UPDATE:
omitting microseconds in datetime.utcnow fixed the problem.
datetime seem to be stored correctly (e.g. 2023-04-24T09:02:02.682648Z via CLI) but when fetched via Sqlalchemy query,
it seems as datetime microsecond part is truncated to 5 digits. Must be 6.
With Sqlalchemy 2.0:
when defining a DateTime column in table model as:
..., default=datetime.datetime.utcnow)
I get the following error at query:
File "/venv/lib/python3.8/site-packages/sqlalchemy/engine/result.py", line 521, in <listcomp> return [make_row(row) for row in rows] File "lib/sqlalchemy/cyextension/resultproxy.pyx", line 25, in sqlalchemy.cyextension.resultproxy.BaseRow.__init__ File "lib/sqlalchemy/cyextension/processors.pyx", line 34, in sqlalchemy.cyextension.processors.str_to_datetime ValueError: Invalid isoformat string: '2023-04-24 08:54:34.53687'
it seem to work with:
datetime.datetime.utcnow()
But that datetime is then corresponding to table creation time and not row creation time.
Any suggestion what I can do about it?
The issue does not occur when using Sqlite3.
The text was updated successfully, but these errors were encountered: