Replies: 1 comment 4 replies
-
This is how PostgreSQL stores timestamps, i.e. the timezone information is not persisted and the binary I/O ignores the |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
This is disappointing:
queries.sql
-- name: get_now
select now() ;
ipython session
In [1]: import asyncpg
In [2]: import aiosql
In [3]: dsn = 'postgres://foo@bar/baz'
In [4]: conn = await asyncpg.connect(dsn, server_settings={'TimeZone': 'America/Los_Angeles'})
In [5]: queries=aiosql.from_path('queries.sql', 'asyncpg')
In [7]: results = await queries.get_now(conn)
In [8]: results
Out[8]: [<Record now=datetime.datetime(2022, 2, 26, 0, 52, 24, 105028, tzinfo=datetime.timezone.utc)>]
... and of course it was 4:52 pm here, not 0:52 am.
So, how are we supposed to handle this? Do I have to wrangle the timezone conversion in Python code? That would make timestamptz quite useless with this library, would it not?
Beta Was this translation helpful? Give feedback.
All reactions