Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

timedelta microseconds are stored improperly #105

Open
vsevolod-fedorov opened this issue Jan 14, 2019 · 0 comments
Open

timedelta microseconds are stored improperly #105

vsevolod-fedorov opened this issue Jan 14, 2019 · 0 comments

Comments

@vsevolod-fedorov
Copy link

When we store timedelta python type values to database, it's microseconds are stored improperly:
0:00:00.000005 becomes 0:00:00.500000.
Code sample to reproduce this:

#!/usr/bin/env python

from __future__ import print_function

import os
from datetime import timedelta

try:
    import psycopg2cffi as psycopg2
except ImportError:
    import psycopg2


connection = psycopg2.connect("user=postgres host=shelter password=%s" % os.environ['PGPASSWORD'])
cursor = connection.cursor()
print(cursor.mogrify('select %s;', [timedelta(microseconds=5)]))

With psycopg2 it prints

b"select '0 days 0.000005 seconds'::interval;"

With psycopg2cffi:

b"select '0 days 0.5 seconds'::interval;"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant