一直在用Python连接内部局域网的ORACLE数据库,通过cx_Oracle模块一直连接不得,直到在百度上查看了相关资料之后,才得;主要步骤:
1、安装cx_Oracle模块:
pip install cx_Oracle
2、将连接oracle数据库的客户端instantclient_11_2中的tnsnames.ora进行配置;\instantclient_11_2\NETWORK\ADMIN目录下的tnsnames.ora;
# tnsnames.ora Network Configuration File: C:\instantclient_11_2\NETWORK\ADMIN\tnsnames.ora
# Generated by Oracle configuration tools.
server03.world(自定义) =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 服务器IP)(PORT = 服务器端口))
(ADDRESS = (PROTOCOL = TCP)(HOST = 服务器IP)(PORT = 服务器端口))
(LOAD_BALANCE = yes)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME=服务器标志名)
)
)
3、将instantclient_11_2中的oci.dll,oraocci11.dll,oraociei11.dll这3个文件拷贝到python的\Anaconda3\Lib\site-packages目录下;
然后测试连接成功,可以进行ORA数据库操作了!!