【发布时间】:2017-07-17 17:31:59
【问题描述】:
我想使用 python 查询数据库
这是我的代码:
import cx_Oracle
import os
def GetDatabase(queryCommand, row):
conn = cx_Oracle.connect('Bell/Bell#@nn.nnn.nnn.nn:1521/Bell')
cur = conn.cursor()
cur.execute(queryCommand)
res=cur.fetchone()
i = 0
while (i < row):
if cur.rowcount == row:
print res
res=cur.fetchone()
i = i + 1
cur.close()
conn.close()
tup1=GetDatabase("select Name from ContactPoint where EmployeeID='1234'",2)
这是输出
('KANOK BKK',)
我只想要值(我不想要括号和逗号)
我尝试打印 tup1[0] 但它不起作用。
【问题讨论】:
-
包含实际 IP 地址可能不是一个好主意。
标签: python oracle plsql automation robotframework