I have pyodbc installed in Windows10(host os) and CentOS docker image.
In Windows10, it is working as expected, however it throws an error on docker image.
ValueError: month must be in 1..12
import pyodbc
conn = pyodbc.connect('DSN=db2; UID=myid; PWD=mypwd')
cursor = conn.cursor()
cursor.execute('select * from mydb.atable')
rows = cursor.fetchall()
Windows 10: host OS
python3.7.4
pyodbc4.0.27
CentOS7: docker image
python3.6.8
pyodbc4.0.30
This is my dockerfile,
FROM centos7
RUN yum -y update
RUN yum install -y python3
RUN pip3 install --upgrade pip
RUN pip3 install wheel
RUN yum install -y python36-devel
RUN yum install -y libevent-devel
RUN yum install -y gcc-c++
Do I miss installing any dev tools on centos?
2
Answers
I had the same problem on another Linux without docker. Same Python version, same pyodbc version. It also happened using pyodbc 3.0.10.
Database: Sybase ASE, OS: Red Hat Enterprise Linux Server release 7.8 (Maipo)
If your resultset contains timestamps, try this:
A colleague created this patch but wants to stay anonymous at the moment.
https://github.com/pucgenie/pyodbc/pull/1
Basically the driver is provided a pointer to a SQLLEN and then fills just 32 bits. pyodbc isn’t able to detect that (-1) was meant instead of (2^32 -1). The patch adds an ugly exceptional handling for 0x00000000FFFFFFFF.
Thanks to @Johannes solution, reading through the code change allowed me explore the problem further.
In the ODBC driver, you have a choice of sqllen4 or sqllen8 driver. I found that selecting the sqllen8 driver in /etc/odbcinst.ini made the problem go away.
There is some documentation here on the matter: http://infocenter.sybase.com/help/index.jsp?topic=/com.sybase.infocenter.dc20116.1570/html/aseodbc/aseodbc5.htm