#获取数据库连接
def Avaiable(self): try: conn=cx_Oracle.connect(self.Oracle_Conn) except cx_Oracle.DatabaseError as msg: logging.exception(msg) print(msg) return conn #数据查询操作 def DataSelect(self,sql): db=self.Avaiable() try: cur=db.cursor() res = cur.execute(sql) result=res.fetchall() except Exception as e: logging.exception(e) print(e) finally: cur.close() db.close() return result
sql_preclose_1 = 'select s_info_windcode,trade_dt,s_dq_preclose from ' + gl.TABLE_PRICES + \
' where trade_dt between %s and %s order by trade_dt desc' %(date_list[-1], date_list[0]) preclose_1 = pd.DataFrame(oracle.DataSelect(sql_preclose_1)) preclose = self._get_transform_df(preclose_1)