Python连接Oracle的方法可以使用cx_Oracle模块。
以下是一个Python连接Oracle数据库的示例代码:
import cx_Oracle# 创建连接connection = cx_Oracle.connect('username', 'password', 'host:port/service_name')# 创建游标cursor = connection.cursor()# 执行SQL查询cursor.execute('SELECT * FROM table_name')# 获取查询结果result = cursor.fetchall()# 打印查询结果for row in result: print(row)# 关闭游标和连接cursor.close()connection.close()请确保已经安装了cx_Oracle模块,并将示例代码中的username、password、host:port/service_name和table_name替换为实际的数据库信息和查询语句。

