


Python installation oracle extension and database connection method
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: http://cx-oracle.sourceforge.net/instantclient -basic
Download address:http://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.msi
instantclient-basic-win32-10.2.0.4.zip
1. Double-click the msi file directly to install cx_Oracle;
2. Unzip instantclient-basic-win32-10.2.0.4.zip and copy all the obtained .dll files to the F:\Python27\Lib\site-packages directory
linux environment :
python26 orracle10
Required software:
##cx_Oracle-5.1.2-10g- py26-1.x86_64.rpmbasic-10.2.0.4.0-linux-x86_64.zip
2. (Refer to http://www.php.cn/ here)
Set environment variables
vi /root/.bash_profile
export ORACLE_HOME=/usr/local/instantclient_10_2 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
Create a symbolic link to this link library
cd $ORACLE_HOME ln -s libclntsh.so.x.x libclntsh.so
Reinstall cx_Oracle
Be 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
Test:
#Python >>> import cx_Oracle >>> db = cx_Oracle.connect('user/psw@114.242.113.91:1521/orcl') >>> print db <cx_Oracle.Connection to user@114.242.113.91:1521/orcl> >>> cr=db.cursor() >>> cr.execute("select * from LOGININFO") <__builtin__.OracleCursor on <cx_Oracle.Connection to user@114.242.113.91:1521/orcl>> >>> 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)] >>>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Solution to permission issues when viewing Python version in Linux terminal When you try to view Python version in Linux terminal, enter python...

When using Python's pandas library, how to copy whole columns between two DataFrames with different structures is a common problem. Suppose we have two Dats...

In Python, how to dynamically create an object through a string and call its methods? This is a common programming requirement, especially if it needs to be configured or run...

How to teach computer novice programming basics within 10 hours? If you only have 10 hours to teach computer novice some programming knowledge, what would you choose to teach...

How does Uvicorn continuously listen for HTTP requests? Uvicorn is a lightweight web server based on ASGI. One of its core functions is to listen for HTTP requests and proceed...

The article discusses popular Python libraries like NumPy, Pandas, Matplotlib, Scikit-learn, TensorFlow, Django, Flask, and Requests, detailing their uses in scientific computing, data analysis, visualization, machine learning, web development, and H

Fastapi ...

How to avoid being detected when using FiddlerEverywhere for man-in-the-middle readings When you use FiddlerEverywhere...
