1. Installing the Oracle Client Instantclient
Note that the installed version, I installed the instantclient_11_1 version of the installation of Instantclient_12_2 version of the time will be due to the system can not parse DLL error.
(1) After the download is complete, unzip to a directory, such as: E:\instantclient_11_1
(2) Add environment variables:
Tns_admin, with a value of E:\instantclient_11_1
Nls_lang, the value is simplified Chinese_china. ZHS16GBK, this is to prevent Chinese garbled
Create a listener file Tnsnames.ora to E:\instantclient_11_1
2, install the corresponding version of the Cx_oracle
: https://pypi.python.org/pypi/cx_Oracle/5.2.1
(1) Here the Oracle client is version 11.1, Python is version 3.4, the operating system is 64-bit, so you need to download the Cx_oracle-5.2.1-11g.win-amd64-py3.4.exe (MD5) version of Cx_oracle
(2) Once the download is complete, double-click the installation directly
(3) After the installation is complete, copy all DLL files under the client (i.e.: E:\instantclient_11_1 directory) to the Python package directory, which is under the C:\Python34\Lib\site-packages folder
3. Use test
Import Cx_oracle
Print (Cx_oracle.clientversion ())
conn = Cx_oracle.connect ("User name/password @ server address/server name")
cursor = Conn.cursor ()
Cursor.execute ("Select address from temp_m_customer_addr_info where ID = ' 103791721 '")
row = Cursor.fetchone ()
Print (ROW)
Cursor.close ()
Conn.close ()
Python3 access to Oracle database with Cx_oracle