Python连接数据库
时间:2021-07-01 10:21:17
帮助过:23人阅读
coding: utf-8
import ibm_db
print ‘Start.....‘
try :
conn = ibm_db.connect(
"DATABASE=dwmm;HOSTNAME=192.168.0.18;PORT=61000;PROTOCOL=TCPIP;UID=dainst;PWD=dainst;",
"",
"")
print "Connect to DWMM Succeed"
except :
print "Connect to DWMM Failed"
if conn:
sql =
"SELECT * from smy.pk10"
stmt =
ibm_db.exec_immediate(conn, sql)
result =
ibm_db.fetch_both(stmt)
print type(result)
while( result ):
#print len(result)
pass
#for key in result:
#print key,‘=‘,result[key]
#print "Result :", result[1],result[2],result[9]
#for i in range(0,len(result)):
# print result[i]
result = ibm_db.fetch_both(stmt)
Python连接数据库
标签:fail toc type base immediate tcp host 数据 sel