程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Liunx python3 connecting Oracle

編輯:Python

One 、 Reference link :

linux Server running python-cx_Oracle:DPI-1047:cannot locate a 64-bit oracle client library:“libclntsh.so“ terms of settlement _Gluttony-- The blog of -CSDN Blog

I've really searched all over the blog , It's not done until you throw up .

Two 、 background :

stay linux Server , Use python3 Connect oracle

linux edition centos 6.5  x86_64   64 Bit

python3.7

3、 ... and 、 install

3.1 install  instantclient

1、 download  instantclient-basic-linux.x64-12.2.0.1.0.zip

Download address :

Instant Client for Linux x86-64 (64-bit)

 

2、 stay opt Under the new oracle file

mkdir -p  /opt/oracle
cd /opt/oracle  

   

3、 take  instantclient-basic-linux.x64-12.2.0.1.0.zip Put it in oracle Under the document

a、 take  instantclient-basic-linux.x64-12.2.0.1.0.zip Put it in oracle Under the document

b、 decompression

unzip instantclient-basic-linux.x64-12.2.0.1.0.zip

Establishing a connection , Just execute the following commands in sequence

cd /opt/oracle/instantclient_12_2
ln -s libclntsh.so.12.1 libclntsh.so
ln -s libocci.so.12.1 libocci.so

sudo sh -c "echo /opt/oracle/instantclient_12_2 > /etc/ld.so.conf.d/oracle-instantclient.conf"        
     

sudo ldconfig

3.2  install  cx_Oracle==8.3.0

pip3 install cx_Oracle==8.3.0

----------------------------- That's it -----------------------------

Four 、 Error handling

4.1 cx_Oracle.DatabaseError: ORA-24454: The client hostname is not set

One line of instructions to solve

sudo /bin/bash -c "echo '127.0.1.1 ${HOSTNAME}' >> /etc/hosts"

5、 ... and 、 other

When not installed instantclient when , perform python The script will report an error .

  • During handling of the above exception (DPI-1047: Cannot locate a 64-bit Oracle Client library: "/lib64/libc.so.6: version `GLIBC_2.17' not found (required by /opt/oracle/instantclient/lib/libclntsh.so)". See https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html for help), another exception occurred:

Prompt you to follow  https://cx-oracle.readthedocs.io/en/latest/user_guide/installation.html 

This connection to solve , I tried the method of this connection for half a day , It's not done , Finally, I got it with my blog .

I guess it must be the version , Last use 12 The version of is done . 


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved