Pyodbc on intersystems Caché int overflow

307 Views Asked by At

Just got my hands on a database server running under Intersystems Caché. I tried using PyOdbc as I usually do,

import pyodbc 
import pandas as pd
import numpy as np
server = '192.168.XX.XX'
database = 'XXXX' 
username = 'XXXX'
port ='XXXX'
password = 'XXXX' 
cnxn = pyodbc.connect('DRIVER={InterSystems ODBC35};SERVER='+server+';PORT='+port+';DATABASE='+database+';UID='+username+';PWD='+ password)
cursor = cnxn.cursor()

But when i try to query certain tables I have an error and i can't find how to solve it... It seems like I have an int overflow issue : can't query some tables because the ID columns is too big ; can't do a count(*) if the table is too big... Here is a more detailled example :

q="SELECT count(*)/1000000000 FROM Anterieur.Audit"
cursor.execute(q)
columns = [column[0] for column in cursor.description]
X=cursor.fetchall()
X=[list(e) for e in X]
df=pd.DataFrame(X,columns=columns)

This works and returns

|   | Expression_1 |
|---|--------------|
| 0 |3.15530572400 |

But if do the "normal" query with

q="SELECT count(*) FROM Anterieur.Audit"

I get

Error                                     Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_1516/2089779472.py in <module>
     24             q='SELECT count(*) FROM Anterieur.Audit'
     25             cursor.execute(q)
---> 26             X=cursor.fetchall()
     27             X=[list(e)for e in X]
     28             df=pd.DataFrame(X)

Error: ('HY019', '[HY019] [Cache ODBC][State : HY019][Native Code 22003]\r\n[XXXX\\Anaconda3\\python.exe]\r\nERREUR #388: Erreur inconnue, code 22003 (22003) (SQLGetData)')

Thanks for your help

0

There are 0 best solutions below