- Notifications
You must be signed in to change notification settings - Fork 437
Closed
Description
- asyncpg version: 0.17.0
- PostgreSQL version: 10.3
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: reproduced with a local install - Python version: 3.6.5
- Platform: Linux x86_64
- Do you use pgbouncer?: no
- Did you install asyncpg with pip?: yes
fromdatetimeimportdatetimeimportasyncioimportasyncpgasyncdefmain(): pool=awaitasyncpg.create_pool( database='postgres', user='postgres', host='127.0.0.1', password='1234', port=2000 ) asyncwithpool.acquire() asconnection: dt_in=datetime(1970, 1, 1, 20, 31, 23, 648000) dt_out=awaitconnection.fetchval("SELECT '%s'::timestamp"%dt_in) op='=='ifdt_in==dt_outelse'!='print('%s %s %s'% (dt_in, op, dt_out)) loop=asyncio.get_event_loop() loop.run_until_complete(main())Output:
1970-01-01 20:31:23.648000 != 1970-01-01 20:31:24.648000 But in psql all works fine:
postgres=# select '1970-01-01 20:31:23.648000'::timestamp; timestamp ------------------------- 1970-01-01 20:31:23.648 (1 row) I guess there is a problem with time parsing in asyncpg.
Maybe seconds were rounded somewhere, like this:
>>> d datetime.datetime(1970, 1, 1, 20, 31, 23, 648000) >>> d.timestamp() 63083.648 >>> int(d.timestamp()) % 60 23 >>> round(d.timestamp()) % 60 24 Metadata
Metadata
Assignees
Labels
No labels