To enable Python to operate the Oracle database, you must first install the cx_Oracle package. You can obtain the installation package through the following address:
To enable Python to operate the Oracle database, you must first install the cx_Oracle package. You can obtain the installation package through the following address:
1. To enable Python to operate the Oracle database, first install the cx_Oracle package. You can obtain the installation package through the following address:
[Plain]
2. You also need some class libraries of oracle. You need to install the Oracle Instant Client package on the machine running python.
[Plain]
Find the package that meets your platform and install it. Here I use the rpm package, so run the following command to install
[Plain]
$ Sudo rpm-ivh oracle-instantclient11.2-basic-11.2.0.3.0-1.i386.rpm
After installation, you need to set the environment variables as follows:
[Plain]
$ Export LD_LIBRARY_PATH =$ {LD_LIBRARY_PATH}:/usr/lib/oracle/11.2/client/lib
3. Create a simple python file and test whether the installation is successful.
[Python]
4. The following is a database table creation and insertion Operation.
[Python]
5. next let's look at the query. there are usually two ways to query: one is to use cursor. fetchall () is used to obtain all query results and then iterate over one row. fetchone () gets a record until the obtained result is null. Let's take a look at the following example:
[Python]