数据库连接池
尝试不一样的写法
class sql():
# 对SQL语句进行封装,当SQL语句比较多的时候,我们不用重复写连接语句
def res(self):
self.cursor.execute("select process,client_process,status,sequence#,block# from v$managed_standby where process='MRP0'")
row = self.cursor.fetchone()
print row
# 集成父类
class Main(sql):
# 连接信息
def conn(self):
self.conn = cx_Oracle.connect('trade/oracle@192.168.30.134/orcl')
self.cursor = self.conn.cursor()
self.res()
def run(self):
self.conn()
if __name__ == '__main__':
b = Main()
b.run()
每天学习一点点,重在积累!