- Notifications
You must be signed in to change notification settings - Fork 435
Closed
Description
I'm using asyncpg 0.11.0 and I hit a problem with a table containing an INTERVAL column.
Consider the following script:
import asyncio import asyncpg SETUP_SQL = """\ CREATE TABLE schedules ( id serial not null primary key, name text, delay interval ) """ INSERT_SQL = """ INSERT INTO schedules (name, delay) VALUES ('Foobar', '5 years') """ FETCH_SQL = """ SELECT delay FROM schedules WHERE name = 'Foobar' """ CLEANUP_SQL = """ DROP TABLE schedules """ async def run(): conn = await asyncpg.connect(user='lele', password='lele', database='test', host='127.0.0.1') await conn.execute(SETUP_SQL) try: await conn.execute(INSERT_SQL) delay = await conn.fetchval(FETCH_SQL) print(delay) finally: await conn.execute(CLEANUP_SQL) await conn.close() def main(): loop = asyncio.get_event_loop() loop.run_until_complete(run()) if __name__ == '__main__': main()It creates a sample table and inserts one record, with a delay value of five years, and executing it I get:
$ python test.py 1800 days, 0:00:00 Commenting out the CLEANUP_SQL execution, with psql I get:
test=# select * from schedules; id | name | delay ----+--------+--------- 1 | Foobar | 5 years and with pgcli, that uses psycopg2, I get:
lele@test> select * from schedules; +------+--------+--------------------+ | id | name | delay | +======+========+====================+ | 1 | Foobar | 1825 days, 0:00:00 | +------+--------+--------------------+ Why am I getting back 1800 days when using asyncpg?
Metadata
Metadata
Assignees
Labels
No labels