嘗試不同的寫法python
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()