Python 連線oracle 報錯 :oci.dll is not the correct architecture 解決方案
阿新 • • 發佈:2018-12-30
完整錯誤:DPI-1047: 64-bit Oracle Client library cannot be loaded: "D:\app\xyg\product\11.2.0\client_1\bin\oci.dll is not the correct architecture"
原因:
instantclient版本為32位,需更換成64位。
解決方案:
下載完成後,解壓得到 資料夾 instantclient_11_2
2 將整個資料夾移動到oracle安裝目錄,client子資料夾內
3. 新增環境變數(下圖為win10系統)
4. 重啟python, 成功連線oracle。
5.我在使用python連線oracle12.2.2的時候,報以下錯誤: cx_Oracle.DatabaseError: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
譯為: cx_Oracle.DatabaseError: ORA-12514: TNS: 監聽程式當前無法識別連線描述符中請求的服務
最後我發現連線python連線cx_oracle時,要用SERVICE_NAME
,而不是sid
,至於原因,我再查查~~~
首先,在用管理員賬號登陸oracle,查詢SERVICE_NAME:
select value from v$parameter where name like '%service_name%';
- 1
其次,將查詢到的service_name替換sid即可
如:
pool = PooledDB(cx_Oracle, user = "trump", password = "123456", dsn = "192.168.1.12:1523/EE.oracle.docker",mincached=2,maxcached=2,maxshared=2,maxco