2017-07-28 75 views
0

我使用Docker在本地主機(主機)上運行虛擬Oracle數據庫服務器。使用python訪問oracleDB時出錯

當我在shell(bash)中使用它時,它工作的很好。

但是我想讓它從python界面訪問。

cx_Oracle安裝(Python接口用於Oracle),

,但它不是我的Python代碼訪問(jupyter筆記本)。 代碼如下

import cx_Oracle 
con = cx_Oracle.connect("system/[email protected]:8080") 

錯誤代碼那麼簡單:

DatabaseError        Traceback (most recent call last) 
<ipython-input-8-681e47c38e7c> in <module>() 
----> 1 con = cx_Oracle.connect("system/[email protected]:8080") 

DatabaseError: ORA-12537: 
+0

雖然您正在使用的'easy connect'連接字符串語法有多種默認值,但它們並不常見。你可能只需要找到數據庫的「服務名稱」,幷包括:'con = cx_Oracle.connect(「system/oracle @ localhost:8080/whateveryourservicenameis」)' –

回答

0

我不知道,你可以使用cx_Oracle.connect與這樣的端口。你可能可以但我會檢查數據源名稱(dsn)。


首先,嘗試連接時沒有:8080。如果這不起作用,請在下面嘗試。


從命令行進入python交互模式。 python -i

import cx_Oracle

dsn = cx_Oracle.makedsn('localhost', '8080')


如果沒有找到的東西,看看伯利森。該網站總是有助於解決ORA問題。

http://www.dba-oracle.com/t_ora_12537_tns_error.htm

和當然,我假設你已經有這個文檔:

http://cx-oracle.readthedocs.io/en/latest/module.html?highlight=connect


而且,假設你是以下的指南,你可能想將其鏈接的URL中評論或您的原始文章。

相關問題