python链接Oracle数据库的代码
""" 作者:皮蛋编程(https://www.pidancode.com) 创建日期:2022/3/23 功能描述:python链接Oracle数据库的代码 """ import cx_Oracle def hello(): """ Hello cx_Oracle示例: 1)打印数据库版本信息. 2)查询表数据. """ conn = cx_Oracle.connect("obs61", "obs61", "tx8i.hp") cur = conn.cursor() try: print("Oracle Version:%s" % conn.version) print("Table SUB_POLICY rows:") cur.execute('select * from wlan_future_event') for row in cur: print(row) finally: cur.close() conn.close() hello()
以上代码在Python3.9环境测试通过
相关文章