用Python訪問Oracle
Despite the beaming praise for the simplicity of the cx_Oracle project on their SourceForge page, I had trouble using the Python module to create a connection to an Oracle database. It turns out that the module is quite nice once you get past a couple of problems that have nothing to do with the cx_Oracle module. In my case, my computer’s environment and some confusing information on the Internet were the cause of my troubles. So here I have organized some hints to help you if you are unfortunate and cannot immediately make a successful connection to your Oracle database using cx_Oracle.
Install the Correct Version of cx_Oracle
This was my biggest problem, though I didn’t realize it for a while. The cx_Oracle project has separate binary distributions for both OS and Oracle version, which support Windows and CentOS for Oracle 10.2, 11.1 and 11.2. On Windows for sure, installing the wrong binary will result in a broken installation. However, it’s not necessarily as simple as knowing which version your Oracle database is at.
Here’s what happened in my case. I have an Oracle ODBC driver installed on my Windows XP installation (OraClient10g) but I want to connect to an 11g database. I first assumed that I needed to install the 11g version of cx_Oracle and found that assumption to be wrong. I think because of the ODBC driver version, I had to install the 10g version of cx_Oracle. I simply could not connect to my database otherwise. I don’t have a way to confirm this ODBC complication because I don’t have authority to install different versions of drivers but it makes sense to me.
The indication I got that my connection was not working was the following error from my Python program:
Install the Correct Version of cx_Oracle
This was my biggest problem, though I didn’t realize it for a while. The cx_Oracle project has separate binary distributions for both OS and Oracle version, which support Windows and CentOS for Oracle 10.2, 11.1 and 11.2. On Windows for sure, installing the wrong binary will result in a broken installation. However, it’s not necessarily as simple as knowing which version your Oracle database is at.
Here’s what happened in my case. I have an Oracle ODBC driver installed on my Windows XP installation (OraClient10g) but I want to connect to an 11g database. I first assumed that I needed to install the 11g version of cx_Oracle and found that assumption to be wrong. I think because of the ODBC driver version, I had to install the 10g version of cx_Oracle. I simply could not connect to my database otherwise. I don’t have a way to confirm this ODBC complication because I don’t have authority to install different versions of drivers but it makes sense to me.
The indication I got that my connection was not working was the following error from my Python program:
CODE:
cx_Oracle.DatabaseError: ORA-24315: illegal attribute typeThis is a vague error that, I suppose, has something to do with the mismatch between the cx_Oracle code and the ODBC driver. Once I installed the cx_Oracle version that matched my ODBC driver version I was able to successfully connect.來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/301743/viewspace-752617/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle外網訪問Oracle
- Oracle 訪問路徑Oracle
- python應用系統訪問瀚高庫Python
- Holer實現Oracle外網訪問Oracle
- Oracle資料庫限制訪問IPOracle資料庫
- 【Python實戰】用程式碼來訪問1024網站Python網站
- Python 訪問限制 private publicPython
- python-訪問者模式Python模式
- python如何訪問網頁Python網頁
- Python使用SQLAlchemy訪問MemFireDBPythonSQL
- 如何限制ip訪問Oracle資料庫Oracle資料庫
- Oracle/MySQL透過odbc訪問PostgreSQL for LightDBOracleMySql
- Oracle 透過透明閘道器 訪問 mysqlOracleMySql
- Oracle 通過透明閘道器訪問mysqlOracleMySql
- LightDB/postgresql內建特性之訪問oracle之oracle_fdw介紹SQLOracle
- 關於python訪問字典的方法Python
- Python連線訪問mongodb副本集PythonMongoDB
- python描述器的訪問順序Python
- Python使用 Kubernetes API 訪問叢集PythonAPI
- Oracle透明閘道器訪問SQLServer資料庫OracleSQLServer資料庫
- Oracle透明閘道器訪問MySQL資料庫OracleMySql資料庫
- Oracle RAC Cache Fusion 系列十三:PCM資源訪問Oracle
- Oracle資料訪問元件ODAC的安裝方法Oracle元件
- 透過Kerberos認證訪問Oracle11gROSOracle
- 使用應用程式(Java/Python)訪問MaxCompute Lightning進行資料開發JavaPython
- Oracle 11.2.0.4 透過透明閘道器訪問mysql 8.0.16OracleMySql
- Python 訪問和設定私有屬性Python
- python如何訪問元組中的元素Python
- WEB應用訪問緩慢的問題定位Web
- python--django專案如何設定用自己的iP地址訪問專案PythonDjango
- Python學習之旅:訪問MySQL資料庫PythonMySql資料庫
- Python如何訪問閉包中的變數Python變數
- Python3訪問、更新和刪除列表Python
- loki: python3訪問loki介面的例子LokiPython
- Angular應用解決跨域訪問的問題Angular跨域
- SpringBoot 實戰 (六) | 用 JdbcTemplates 訪問 MysqlSpring BootJDBCMySql
- 安裝oracle11g碰到“無法訪問臨時位置”的問題Oracle
- Python中訪問私有屬性和私有方法Python
- Python 獲取檔案建立、訪問、修改時間Python