DSaccess.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:Otop 作者: fcbarclo 项目源码 文件源码
def DBGetCursorData(self, sql, id_th):
                result = []
                tryconn = 0
                while tryconn<2:
                        try:
                connection = self.Voracle_connect.acquire()
                                cursor = connection.cursor()

                if id_th >= 0:
                    self.WinThUpdate(id_th, self.TH_SQL_RUNNING) 

                                cursor.execute(sql)
                                cursor.arraysize = 1500

                if id_th >= 0:
                    self.WinThUpdate(id_th, self.TH_ROW_FETCHING) 

                                for row in cursor:  # fetch rows
                        newrow=[]

                        for i in range(0,len(row)):
                                if type(row[i]) is cx_Oracle.LOB:
                                        newrow.append(row[i].read() )   # read lob locator
                                else:
                                        newrow.append(row[i])
                                        result.append(list(newrow))

                                cursor.close()

                self.Voracle_connect.release(connection)
                                break
                        except Exception  as err:
                                result=[]
                if id_th >= 0:
                    self.WinThUpdate(id_th,self.TH_REQUEST_DB_CONN) 

                                self.lockdbconn.acquire()

                                if self.DBpingconn(self.Voracle_connect) == 0:   #  global connection handle status broken
                    if id_th >= 0:
                        self.WinThUpdate(id_th,self.TH_DB_RECONNECTING) 

                                        oconn = self.DBreconnect()

                                        if oconn < 0:    #error on reconnecting
                                                tryconn = 2  # exit  try
                                                result=-1
                                        else:
                                                tryconn += 1
                                else:
                                        tryconn = 2 #exit try
                                        result=-1

                                self.lockdbconn.release()

                return(result)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号