Author Topic: accessing ibm i database from Python  (Read 277 times)


  • Newbie
  • *
  • Posts: 2
    • View Profile
accessing ibm i database from Python
« on: November 28, 2018, 06:15:53 pm »
Good morning.

I have Python 3.7.1 installed on my windows 10 PC. I ma using Idle as editor. I am trying to do basic connection to an IBM i server.

import ibm_db
import ibm_db_dbi

database = "IBMINAME"
user = "JOEL"
password = "PASSWORD"

#ibm_db_conn = ibm_db.connect(database,user,password)

#conn = ibm_db_dbi.Connection(ibm_db_conn)


sql = "select GFCUS from KFILFBI.GFPF"
cursor = conn.cursor()
for row in cursor.fetchall():

I only get a printout of AA on my idle console. Any ideas why? There are no errors on the Idle console. When i use port 50000 or 60000, i get :

Exception: [IBM][CLI Driver] SQL30081N  A communication error has been detected. Communication protocol being used: "TCP/IP".  Communication API being used: "SOCKETS".  Location where the error was detected: "".  Communication function detecting the error: "connect".  Protocol specific error code(s): "10061", "*", "*".  SQLSTATE=08001

Another thing, when i use port 8471, I do not get the SQL30081N  error above. 8471 is the port used by ibm database server jobs. But still, i only get AA, it looks like the code get stuck on the connection part, it doesnt get to the line where BB is supposed to be printed.

I tried adding firewall exceptions for port 8471 and 50000 60000, still same problem.

Do you have any ideas i can work on?

« Last Edit: November 28, 2018, 06:18:27 pm by joelj »

Share on Facebook Share on Twitter

Like Like x 1 View List


  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: accessing ibm i database from Python
« Reply #1 on: November 29, 2018, 05:40:12 am »
was able to make it work using pyodbc. very useful reference here:

Many thanks to the Omi Chiba.