Comments (5)
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.
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.
Are you still experiencing this with latest version of pyODBC? If so, please post an ODBC trace for more investigation.
from pyodbc.
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.
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)
- Transaction is not getting rolled back HOT 7
- MACOS 系统使用 HOT 4
- Memory leak when passing strings within table value parameter to stored proc HOT 9
- Add support for SQLTablePrivileges
- Login Timeout Error when connecting to Synapse database using pyodbc python library in Azure synapse notebook via Managed Identity HOT 1
- reference count encoding in the connect function HOT 5
- PyToCType uses internal function removed from Python 3.13 HOT 3
- I am trying to install pyodbc in MacBook Pro M3 chip - arm64. The drivers are installed succesfully for odbc 13,17 and 18. But pyodbc is not able to detect the drivers.:
- I am trying to install pyodbc in MacBook Pro M3 chip - arm64. The drivers are installed succesfully for odbc 13,17 and 18. But pyodbc is not able to detect the drivers. ERROR: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 17 for SQL Server' : file not found (0) (SQLDriverConnect)") HOT 5
- Executing multiple queries HOT 1
- pyodbc.connect() gives an error when executing it with pytest HOT 1
- InterfaceError: Data source name not found with pyodbc despite working with isql HOT 8
- Multiple threads querying same table takes a long time HOT 19
- Timeout not being enforced in SQL query HOT 7
- How to use Federated credentials with service principal to auth the Azure resources HOT 7
- Ansi to Unicode conversion error (noob) HOT 9
- How to surface azure active directory service principal related errors HOT 3
- Do we need to close cursor in this case? HOT 9
- Connection pooling broken in 5.1.0 or 5.0.1 (with unixODBC 2.3.12)? HOT 3
- pyodbc.Connection' object has no attribute 'columns'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyodbc.