Thursday, January 12, 2017

Connecting Oracle Database using Python(Cx_Oracle)

Hello Friends , today i will be telling you how to connect to oracle data base using python .

We will be running some queries and also tries to explore other options like insert, running anonymous block etc.

So in order to connect to Oracle data base we need Cx_Oracle module .(Download)

Make sure that you have one entry in your registry for python also the version of cx_Oracle should be compatible with your system.

Lets see a sample implementation.

I have created a table friends in my oracle database(localhost).And i would be trying to connect and retrieve this data using python.












The result will  be of type tuple , so in order to get the specific result we can use the tuple index to get the data. For eg values[0] will print the name of the friends.


No comments:

Post a Comment