Git Product home page Git Product logo

Comments (5)

mkleehammer avatar mkleehammer commented on July 17, 2024

What version of pyodbc? And are you using unixODBC? If so, did you compile it yourself with the default flags or did you change any?

Due to driver bugs I read decimal columns as Unicode instead of a binary structure. My guess is that I'm reading it and the Unicode characters are wider than I expect. unixODBC always uses 2-byte UCS2, so I'll look at each character in 2-byte chunks. If the data is actually 4-byte, it is going to look like [ "2" NUL "0" NUL "2" NUL ... ]. So would stop at the first null terminator and end up with just "2".

from pyodbc.

smoller avatar smoller commented on July 17, 2024

The error occurs through versions 3.0.2 - 3.0.10. I am using unixODBC.

I think what you've described is happening. This is what I get in the logs:

[SQLGetData][139766695343872]PGAPI_GetData: enter, stmt=0x22b9ae0 icol=3
[139766695343872]     num_rows = 1
[139766695343872]     value = '2029139'
[139766695343872]**** PGAPI_GetData: icol = 2, target_type = -8, field_type = 1700, value = '2029139'
[139766695343872]copy_and_convert: field_type = 1700, fctype = -8, value = '2029139', cbValueMax=200
[139766695343872]DEFAULT: len = 28, ptr = '2'
[139766695343872]    SQL_C_WCHAR, default: len = 28, cbValueMax = 200, rgbValueBindRow = '2'

Anything I can do to fix this?

from pyodbc.

v-chojas avatar v-chojas commented on July 17, 2024

Are you still experiencing this with latest version of pyODBC? If so, please post an ODBC trace for more investigation.

from pyodbc.

Learner-B avatar Learner-B commented on July 17, 2024

Is this issue resolved? I have latest version of PYODBC - 4.0.30. I am still getting the same issue when write data from SQL Server which having different datatypes into File?

Instead of getting Date and Decimal as below
'2020-03-01 00:00:00'|10.10

writing the data into file as
datetime.datetime(2019| 9| 18| 0| 0) | Decimal('0')

from pyodbc.

gordthompson avatar gordthompson commented on July 17, 2024

Unable to reproduce with (reasonably) current versions:

Python version: 3.6.5 (default, Apr 1 2018, 05:46:30) [GCC 7.3.0]
pyodbc version: 4.0.30
ODBC driver: psqlodbcw.so [10.01.0000]

crsr.execute("INSERT INTO m (day, string, volume) VALUES ('2015-04-30', 'blah', 2029139)")
print(crsr.execute("SELECT * FROM m").fetchone())
# (datetime.date(2015, 4, 30), 'blah', Decimal('2029139'))

from pyodbc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.