Python is a very popular programming language that can be used for general purposes. It is an interpreted language with object-oriented features. At my blog I will give some information about Python how you can use it for database security subjects. at this note I will explain how you can connect Oracle from Python . I assume that you already installed Python to your PC. In the future at another note I will explain how you can install and run Python at your Windows Client.
In order to connect Oracle from Python in Windows ; you need to downloads and install Python interface to Oracle from this website
According to your installation choose 32 bit or 64 bit module.
Put this interface into Scripts directory ( C:\Python361\Scripts ) and run pip program with install option
pip install cx_Oracle-6.0rc1-cp36-cp36m-win32.whl
Now you installed Oracle interface for Python. The second operation is to make reachable oci.dll from Python to call Oracle libraries.
For this reason you need to install Oracle instant client. You can download Oracle instant client from below websites.
At this website you can see many packages to download but only Oracle Instant Client package is enough for Python.
I download both of them and I put them in different directories. You have to just unzip these packages like below.
Now you have to add the directory of the instant package into PATH environment variable like below. To change PATH variable follow below steps
In Control Panels choose System;
From this page choose Advanced system settings
choose Environment Variables;
In Environment Variables; choose PATH and add Oracle Instant Client path.
After changing PATH variable I advice to restart your client.
Now you can use Python module cx_Oracle to connect Oracle database. I wrote below program to check cx_Oracle module. This program connects to an Oracle database and shows its version. At the same time It executes a small query to get database name
you can get the source of this code from github
Check the program. Simply run it. You should get below result.
Now you installed and configured Oracle package in Python. You can use it your projects.