This article mainly introduces the installation of Oracle extensions and database connection methods in Python. It analyzes in more detail the installation steps, operating techniques and precautions for downloading Oracle extensions in Python and Windows and Linux environments. Friends in need can refer to the following
The example in this article describes the installation of Oracle extension and database connection method in Python. Share it with everyone for your reference, the details are as follows:
Download:
cx_Oracle download address: cx-oracle.sourceforge.net/
instantclient-basic download address :www.oracle.com/technetwork/database/features/instant-client/index-097480.html
window environment:
python27 oracle10
Required software:
##cx_Oracle-5.1.2-10g.win32-py2.7.msiinstantclient-basic-win32-10.2 .0.4.
zip
linux environment:
python26 orracle10Required software:
##cx_Oracle-5.1.2-10g-py26-1.x86_64.rpmbasic-10.2.0.4.0 -linux-x86_64.zip
1. rpm -ivh cx_Oracle-5.1.2-10g-py26-1.x86_64.rpm
vi /root/.bash_profile
export ORACLE_HOME=/usr/local/instantclient_10_2 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
Run source /root/.bash_profile to make the changes take effect
Create a symbolic link to this link library
cd $ORACLE_HOME ln -s libclntsh.so.x.x libclntsh.so
Reinstall cx_OracleBe careful to add the --nodeps parameter, otherwise the above error will be reported
[root@BJ-UPDATE-01 ~]# rpm -ivh -- nodeps cx_Oracle-5.0.1-10g-py24-1.x86_64.rpm
#5.0.3 version does not need to add the --nodeps parameter
#Python >>> import cx_Oracle >>> db = cx_Oracle.connect('user/psw@114.242.113.91:1521/orcl') >>> print db>>> cr=db.cursor() >>> cr.execute("select * from LOGININFO") > >>> rs=cr.fetchall() >>> print rs [('40288a8542746fd90142746fdbb50001', 'cccccc', 1, 1, None, None, None), ('40288a85427474b601427474b8270001', 'eeee', 1, 1, None, None, None), ('40288a854273bce0014273bee6310002', 'dddddd', 0, 0, None, None, None), ('40288a854274532d014274532f600001', 'cccccc', 1, 1, None, None, None), ('40288a8542747c750142747c77ac0001', 'eeee', 1, 1, None, None, None), ('40288a8542744fb30142744fb5e90001', 'cccccc', 1, 1, None, None, None)] >>>
1.
Python free video tutorialPython object-oriented video tutorialPython Learning ManualThe above is the detailed content of Detailed explanation of Oracle installation and database connection methods. For more information, please follow other related articles on the PHP Chinese website!