一个Tuple转换为List的问题
时间:2011-05-24
来源:互联网
使用Cx_Oracle链接数据库,然后从数据库查询数据,Cx_Oracle返回的是Tuple值,想把Tuple转换为List的时候一直报错;
import sys
import cx_Oracle
ora_ip="10.1.1.244"
ora_port="1522"
SERVICE_NAME="ora10g"
ora_dsn=cx_Oracle.makedsn(ora_ip,ora_port,SERVICE_NAME)
connection = cx_Oracle.connect("username","passwd",ora_dsn)
cursor = connection.cursor()
list_len =''
list =''
re_num=''
result=()
r_temp =''
lo_num=0
t_result =[]
ex_sql="select distinct id from sq_id"
try:
list=cursor.execute(ex_sql)
###cursor.execute(u"commit")
result=list.fetchall()
connection.close()
for r in result:
t_result.append(list(r))
except cx_Oracle.DatabaseError, exc:
error, = exc.args
print >> sys.stderr, "Oracle-Error-Code:", error.code
print >> sys.stderr, "Oracle-Error-Message:", error.message
最后总是报 t_result.append(list(r))
TypeError: 'OracleCursor' object is not callable。
有没大侠遇到过这样的问题?为什么不能把Tuple转换为List呢?
import sys
import cx_Oracle
ora_ip="10.1.1.244"
ora_port="1522"
SERVICE_NAME="ora10g"
ora_dsn=cx_Oracle.makedsn(ora_ip,ora_port,SERVICE_NAME)
connection = cx_Oracle.connect("username","passwd",ora_dsn)
cursor = connection.cursor()
list_len =''
list =''
re_num=''
result=()
r_temp =''
lo_num=0
t_result =[]
ex_sql="select distinct id from sq_id"
try:
list=cursor.execute(ex_sql)
###cursor.execute(u"commit")
result=list.fetchall()
connection.close()
for r in result:
t_result.append(list(r))
except cx_Oracle.DatabaseError, exc:
error, = exc.args
print >> sys.stderr, "Oracle-Error-Code:", error.code
print >> sys.stderr, "Oracle-Error-Message:", error.message
最后总是报 t_result.append(list(r))
TypeError: 'OracleCursor' object is not callable。
有没大侠遇到过这样的问题?为什么不能把Tuple转换为List呢?
作者: zaibian 发布时间: 2011-05-24
回复 zaibian
cursor.execute(ex_sql)
result=cursor.fetchall()
QUOTE:
try:
list=cursor.execute(ex_sql)
###cursor.execute(u"commit")
result=list.fetchall()
connection.close()
zaibian 发表于 2011-05-24 16:37
list=cursor.execute(ex_sql)
###cursor.execute(u"commit")
result=list.fetchall()
connection.close()
zaibian 发表于 2011-05-24 16:37
cursor.execute(ex_sql)
result=cursor.fetchall()
作者: 106033177 发布时间: 2011-05-24
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28