skip to Main Content

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


  1. 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.

    Login or Signup to reply.
  2. 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

    -rwxr-xr-x 1 1000 1034 5185504 Apr  8 09:23 libsapcrypto.so
    -rwxr-xr-x 1 1000 1034 5413262 Apr  8 09:23 libsapssfs.so
    -rwxr-xr-x 1 1000 1034  499679 Apr  8 09:23 libslcryptokernel.so
    -rwxr-xr-x 1 1000 1034     166 Apr  8 09:23 libslcryptokernel.so.sha256
    -rwxr-xr-x 1 1000 1034 3645535 Apr  8 08:16 libsybdrvodb-sqllen4.so  # <- don't use this one
    -rwxr-xr-x 1 1000 1034 3454884 Apr  9 03:30 libsybdrvodb-sqllen4.so.fbo
    -rwxr-xr-x 1 1000 1034 3655680 Apr  8 09:23 libsybdrvodb-sqllen8.so  # <- use this one
    lrwxrwxrwx 1 1000 1034      25 Aug  7 04:44 libsybdrvodb.so -> ./libsybdrvodb-sqllen4.so
    drwxrwxr-x 5 1000 1034    4096 Aug  7 04:44 locales
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search