Oracle & OleDb

From IronPython Cookbook

An example posted to the IronPython Mailing List, of accessing an Oracle database server using OleDb. The installed version of Oracle was: Oracle Database 10g Express Edition (Universal).

import clr
import System
clr.AddReference("System.Data")

from System.Data import DataSet
from System.Data.OleDb import OleDbConnection, OleDbDataAdapter, OleDbCommand


conStr = "Provider=MSDAORA.1;User ID=name;Password=pwd;Persist Security Info=False"

con = OleDbConnection(conStr)

query = "SELECT * FROM TEST"

adapter = OleDbDataAdapter(query, con)
ds = DataSet()
con.Open()

adapter.Fill(ds, "t1")
for i in range(ds.Tables["t1"].Rows.Count -1):
    print ds.Tables["t1"].Rows[i][0]
    print ds.Tables["t1"].Rows[i][1]
    print ds.Tables["t1"].Rows[i][2]

con.Close()


Back to Contents.

TOOLBOX
LANGUAGES