-
Notifications
You must be signed in to change notification settings - Fork 565
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
fractional seconds dropped when using fast_executemany with PostgreSQL ODBC #1023
Comments
I am able to reproduce the issue. from datetime import datetime
import pyodbc
connection_string = (
"DRIVER=PostgreSQL Unicode;"
"SERVER=192.168.0.199;"
"UID=scott;PWD=tiger;"
"DATABASE=test;"
)
cnxn = pyodbc.connect(connection_string, autocommit=True)
print(cnxn.getinfo(pyodbc.SQL_DRIVER_VER)) # 13.02.0000
crsr = cnxn.cursor()
crsr.execute("TRUNCATE TABLE data_table")
data = [(datetime(2022, 2, 3, 17, 28, 15, 344014),)]
crsr.fast_executemany = True
crsr.executemany("INSERT INTO data_table (dt) VALUES (?)", data)
print(crsr.execute("SELECT * FROM data_table").fetchall())
# [(datetime.datetime(2022, 2, 3, 17, 28, 15), )] The fractional seconds are preserved if Fractional seconds are preserved with A possible explanation for the difference is that PostgreSQL ODBC returns this
whereas msodbcsql returns this
|
Thanks. According to Driver-support-for-fast_executemany this shouldn't impact speed significantly. |
The wiki page has been updated. |
https://docs.microsoft.com/en-us/sql/odbc/reference/appendixes/decimal-digits Looks like buggy ODBC driver. |
Hello,
I've been investigating the issues with ETL that is transferring data from MS SQL to PostgreSQL using following environment:
Was able to reproduce issue without sourcing data from MS SQL Server, just mocking some datetimes.
datetime2(7) from MS SQL should be saved to timestamp(6) in PosgreSQL with 6 digits in milliseconds.
Actual output:
Expected output:
Notice that milliseconds are not saved into PostgreSQL, when executemany is used to save data.
This is how it looks in database:
The text was updated successfully, but these errors were encountered: