python使用Cx_Oracle 连接数据库报错
做了个工具打包的EXE,Oracle客户端的DLL都打包进去了,所有测试正常,交付客户后客户连接数据库时报一下错误。ConnectionFailed:ORA-00604:...
做了个工具打包的EXE, Oracle客户端的DLL都打包进去了, 所有测试正常,交付客户后客户连接数据库时报一下错误。
Connection Failed: ORA-00604: error occurred at recursive SQL level 1
ORA-20000: ˯܊****许可された接続方法以外では利用できません ˯܊***!EORA-06512: at line 25
另之前成功连接过,但是导出数据时有时也会报这个错:
ORA-03113: end-of-file on communication channel
。
求问大神这是什么原因? 展开
Connection Failed: ORA-00604: error occurred at recursive SQL level 1
ORA-20000: ˯܊****许可された接続方法以外では利用できません ˯܊***!EORA-06512: at line 25
另之前成功连接过,但是导出数据时有时也会报这个错:
ORA-03113: end-of-file on communication channel
。
求问大神这是什么原因? 展开
展开全部
# -*- coding:utf-8 -*-#!/usr/bin/env python'''Created on 2014年8月4日 @author: 188007 连接Oracle数据库的class'''import osos.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.ZHS16GBK'import cx_Oracleimport sys class Oracle: ''' python access oracle helper tool class ''' def __init__(self, ip,port,db,user,pwd): self.ip = ip self.port = port self.db = db self.user = user self.pwd = pwd def __GetConnect(self): """ 得到连接信息 返回: conn.cursor() """ if not self.db: raise(NameError,"没有设置数据库信息") dsn=cx_Oracle.makedsn(self.ip,self.port,self.db) self.conn=cx_Oracle.connect(self.user,self.pwd,dsn) cur = self.conn.cursor() if not cur: raise(NameError,"连接数据库失败") else: return cur def ExecQuery(self,sql): """ 执行查询语句 返回的是一个包含tuple的list,list的元素是记录行,tuple的元素是每行记录的字段 调用示例: oracle = Oracle('10.27.95.253','1561','GFDMS','GFITAPPS','GFITAPPS') resList = oracle.ExecQuery("SELECT OBJID,NUMCODE,AREACODE,AREANAME,PROVCODE,PROVNAME,CITYCODE,CITYNAME,TOWNCODE,TOWNNAME,REMARK FROM GFDMS.THZONE ORDER BY NUMCODE") for (AREANAME) in resList: print str(AREANAME).decode('gb2312') """ try: cur = self.__GetConnect() cur.execute(sql) resList = cur.fetchall() #查询完毕后必须关闭连接 self.conn.close() except Exception, err: sys.exit(1) return resList def ExecNonQuery(self,sql): """ 执行非查询语句 调用示例: oracle.ExecNonQuery("insert into THZONE values('x','y')") """ try: cur = self.__GetConnect() cur.execute(sql) self.conn.commit() self.conn.close() except Exception, err: sys.exit(1) # def main():# # oracle = Oracle('10.27.95.253','1561','GFDMS','GFITAPPS','GFITAPPS')# # #返回的是一个包含tuple的list,list的元素是记录行,tuple的元素是每行记录的字段# # oracle.ExecNonQuery("insert into THZONE values('x','y')")# oracle = Oracle('10.27.95.253','1561','GTEST','GTAPPS','GTAPPS')# resList = oracle.ExecQuery("SELECT OBJID,NUMCODE,AREACODE,AREANAME,PROVCODE,PROVNAME,CITYCODE,CITYNAME,TOWNCODE,TOWNNAME,REMARK FROM GTEST.THZONE ORDER BY NUMCODE")# for (AREANAME) in resList:# print str(AREANAME).decode('utf-8')# # if __name__ == '__main__':# main()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询