I am attempting to use pandas.read_sql_query
to call a stored procedure in IBM's db2 and read the results into a dataframe. However when I do so, I receive the following error:
ibm_db_dbi::ProgrammingError: The last call to execute did not produce any result set.
I've called the procedure in IBM Data Studio, to confirm that it works as intended, yielding the anticipated approximately 1000 records. I've also manually queried the table using a select * from table
, with read_sql_query
from my script with success. Therefore I may conclude that the python script is properly configured to work with the database as is the procedure itself. The struggle seems to be in putting the two together. My code is below.
import ibm_db
import ibm_db_dbi
import pandas as pd
cnxn = ibm_db.connect('DATABASE=mydb;'
'HOSTNAME=myHost;'
'PORT=446;'
'PROTOCOL=TCPIP;'
'UID=myUser;'
'PWD=myPassword;', '', '')
conn=ibm_db_dbi.Connection(cnxn)
sql = 'call myschema.getaccountnonrecurringpaging(20230509,0);'
df = pd.read_sql_query(sql, conn)
Package details are listed below:
- python=3.10.4
- pandas=1.5.3
- ibm_db=3.1.1
- operating system = Ubuntu 20.04
- db2: v7r4