faqts : Computers : Programming : Languages : Python : Common Problems : Database Access

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

17 of 22 people (77%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How can I access oracle database using python scripts

Dec 31st, 2002 00:54
maverick b, Smita Agarwal,


The simplest method is the following:
Here i use the cx_Oracle module available from www.computronix.com

#!/usr/bin/python

import os
import sys
import string
dbapi = __import__('cx_Oracle')

import commands

dbh = dbapi.connect(logger_conf.db_dsn)
dbc = dbh.cursor()

dbc.execute("select user_id,user_name,email from users")
rows = dbc.fetchall()
print "\nUSERID:\n",rows[0]
print "\nNAME:\n",rows[1]
print "\nEMAIL:\n",rows[2]


Hope this helps :)