用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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- python訪問oracle時的問題總結PythonOracle
- 用JDBC THIN CLIENT能訪問oracle cluster嗎?JDBCclientOracle
- python應用系統訪問瀚高庫Python
- Oracle 訪問路徑Oracle
- Oracle外網訪問Oracle
- mono 訪問 oracle、mysqlMonoOracleMySql
- Oracle 表訪問方式Oracle
- Oracle 索引訪問方式Oracle索引
- oracle表訪問方式Oracle
- oracle 限定ip訪問Oracle
- Python訪問Oracle的兩種資料獲取方式PythonOracle
- python訪問redis的問題PythonRedis
- Oracle EBS DMZ區訪問問題Oracle
- Oracle訪問表的方式Oracle
- ubuntu下python通過sqlalchemy庫訪問oracle資料庫UbuntuPythonSQLOracle資料庫
- Python 訪問限制 private publicPython
- python如何訪問網頁Python網頁
- Python使用SQLAlchemy訪問MemFireDBPythonSQL
- python-訪問者模式Python模式
- Oracle指令碼(Oracle Scripts) – 檢視索引訪問次數及索引訪問型別Oracle指令碼索引型別
- 用C#訪問HotmailC#AI
- 從Oracle訪問SQL Server(GATEWAYS)OracleSQLServerGateway
- ORACLE 訪問MYSQL 配置筆記OracleMySql筆記
- Oracle 單表訪問路徑Oracle
- .net之oraclecommand訪問oracleOracle
- Oracle資料庫訪問控制Oracle資料庫
- 通過Oracle Gateways 訪問SybaseOracleGateway
- 限定client端IP訪問oracle!clientOracle
- 限定client段ip訪問oracle!clientOracle
- 用.NET新提供的managedprovider來訪問Oracle資料(轉)IDEOracle
- 使用ADO訪問Oracle問題彙總Oracle
- 用訪問控制列表實現網路單向訪問(轉)
- 【Python實戰】用程式碼來訪問1024網站Python網站
- Holer實現Oracle外網訪問Oracle
- Oracle資料庫限制訪問IPOracle資料庫
- oracle 索引訪問的幾種方式Oracle索引
- Oracle使用utl_http訪問webserviceOracleHTTPWeb
- 使用主機命名方法訪問oracleOracle