Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32k
Open
Description
Documentation
This recipe for an adapter does not work as advertised:
def adapt_datetime_iso(val): """Adapt datetime.datetime to timezone-naive ISO 8601 date.""" return val.isoformat()
from:https://github.com/erlend-aasland/cpython/blob/a3711d1541c1b7987941b41d2247f87dae347117/Doc/library/sqlite3.rst?plain=1#L2287-L2289
orhttps://docs.python.org/3/library/sqlite3.html#sqlite3-adapter-converter-recipes
If the argument has a timezone, it will produce a timezone-aware result, contrary to its documentation
Consider the difference between these:
import datetimeprint(datetime.datetime.now(datetime.timezone.utc).isoformat())print(datetime.datetime.now(datetime.timezone.utc).replace(tzinfo=None).isoformat())"""2025-03-28T08:41:09.240880+00:002025-03-28T08:41:09.241046"""
The recipe should instead be like this:
def adapt_datetime_iso(val): """Adapt datetime.datetime to timezone-naive ISO 8601 date.""" return val.replace(tzinfo=None).isoformat()
Metadata
Metadata
Assignees
Projects
Status
No status
Status
Todo