I am trying to create a database connection in Python Script in my DB2 database. When the connection is made, I have to run some different SQL statements.
I have mistaken the problem and read the ibm_db API (), but it can not look right.
Even that which I have so far received:
import import import import import time import import multiprocessing import ram import import import import ibm_db import time From string import maketrans query_str = any conn = ibm_db.pconnect ("Dsn = write", "usrname", "secret") query_stmt = ibm_db.prepare (conn, query_str) ibm_db.execute (query_stmt, "select COUNT (*) accounts From ") Results = ibm_db.fetch_assoc () Print Result Status = ibm_db.close (conn)
But I get an error I really try every thing So I (or, if not everything, but off very close) and I could not get it to work.
I just need to create an automatic test python script which can test different queries with different index and therefore I need to index and remove it.
Hope someone has a solution or maybe I know some example code where I can download and study.
Mastica
It should be: < "Conn = ibm_db.pconnect (" dsn = write "," usrname "," secret ") query_stmt = ibm_db.prepare (conn, query_str) from / p>
query_str =" SELECT COUNT (*) accounts Ibm_db.execute (query_stmt)
Comments
Post a Comment