[DB-SIG] Oracle tables encapsulation

Michel Orengo ORENGM@powell.fabrik.com
Thu, 02 Dec 1999 10:10:00 -0800


Hi Olivier,

I've done something similar with sybase/MS SQL using ODBC. I was kind of proud
of it when I read on the news group the anouncement from Boudewijn Rempt
<boud@rempt.xs4all.nl> about a framework to give an object-oriented access to
relational databases.
He called its stuff "Database Object 0.2.0"

What he did is far more complete than what I did, but quite similar. He uses a
data-dictionnary to create objects/requests. In fact, you can create this data
dictionary with requests to the catalog/system tables to get names of
tables/columns and types.

I think it is worth looking at his project (even if it's more complex than what
you try to do)

Also, on a similar subject, I found an very interesting project from INRIA
called ObjectDriver (http://www.inria.fr/cermics/dbteam/ObjectDriver/). It
provides an object mapping to any relational database. It's really cool, and
you
can query the database with OQL. If I had time, I would create a python binding
to it.
The bad news is that they want to go commercial and they don't know yet the
pricing framework. 

Michel Orengo

____________________Reply Separator____________________
Subject:    [DB-SIG] Oracle tables encapsulation
Author: "Olivier BERGER" <olberger@club-internet.fr>
Date:       12/2/99 2:36 AM

From: Olivier BERGER
Date: Thu, Dec 2, 1999 2:36 AM
Subject: [DB-SIG] Oracle tables encapsulation
To: db-sig
Hi python fans.

I've searched a bit the archives or general Python DB documentation, but
couldn't find any clue on this, so I'm asking you, and pardon me if this is
a really trivial question about Python DB usage...

I'd like to have a Python framework with classes encapsulating the physical
tables and columns of my Oracle database.
For instance, I would have a class called OracleRow which would allow me to
map automatically the results of DCOracle fetch results to an instance of a
subclass of OracleRow.

This would, for instance, give the following :

class MyTable(OracleTable) :
    def __init__(self) :
        OracleTable("mytable")
...

... so that I get a MyTableRow class corresponding to rows in the MYTABLE
oracle table, and then I would be able to do something like

cursor.execute("select * from mytable")
for r in cursor.fetchall :
    instance = MyTableRow(r)
    do_something(instance)

and if MYTABLE contained the ID, NAME, ADDRESS columns, then I would be able
to do a :

def do_something(mytablerow) :
    print mytablerow.id, mytablerow.name, mytablerow.address

As you see this kind of framework would allow me to use the MyTableRow
containing attributes allready mapped to the corresponding columns of the
Oracle table. This would have been made by analysing the oracle meta-model
internal tables in order to know the proper mapping.

Such a framework allows automatical encapsulation of low-level tables into
obect instances, thus facilitating the algorithms writing.

Have you experienced this kind of framework, and can you direct me to the
corresponding source code (if available) so that I won't code it myself
(with all the resulting errors... ;)

Thanx in advance.

Olivier Berger.




_______________________________________________
DB-SIG maillist  -  DB-SIG@python.org
http://www.python.org/mailman/listinfo/db-sig

----------
Received: from dinsdale.cnri.reston.va.us by powell.fabrik.com
        with SMTP (Fabrik F07.3-000)
        id SINN.15067201@powell.fabrik.com ; Thu, 2 Dec 1999 02:39:47 -0800
Received: by dinsdale.python.org (Postfix, from userid 60001)
        id 6938F1CE96; Thu,  2 Dec 1999 05:38:59 -0500 (EST)
Delivered-To: db-sig@dinsdale.python.org
Received: from python.org (parrot.python.org [132.151.1.90])
        by dinsdale.python.org (Postfix) with ESMTP id 2A7551CD52
        for <db-sig@dinsdale.python.org>; Thu,  2 Dec 1999 05:38:57 -0500 (EST)
Received: from gw.capgemini.fr (gw.capgemini.fr [194.3.247.254])
        by python.org (8.9.1a/8.9.1) with ESMTP id FAA14132
        for <db-sig@python.org>; Thu, 2 Dec 1999 05:38:49 -0500 (EST)
Received: from prenoms.capgemini.fr (capmail.capgemini.fr [194.2.91.200])
        by gw.capgemini.fr (8.9.1/8.9.1) with ESMTP id LAA08345
        for <db-sig@python.org>; Thu, 2 Dec 1999 11:38:46 +0100 (MET)
Received: from OBerger.mcotlc.bk.fr (localhost [127.0.0.1])
        by prenoms.capgemini.fr (8.9.3/8.9.3) with SMTP id LAA03568
        for <db-sig@python.org>; Thu, 2 Dec 1999 11:38:47 +0100 (MET)
Message-ID: <006b01bf3cb1$2c71d9c0$640105c0@mcotlc.bk.fr>
Reply-To: "Olivier BERGER" <olberger@club-internet.fr>
From: "Olivier BERGER" <olberger@capgemini.fr>
To: <db-sig@python.org>
Date: Thu, 2 Dec 1999 11:36:00 +0100
X-Priority: 3
X-MSMail-Priority: Normal
X-Mailer: Microsoft Outlook Express 5.00.2314.1300
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300
Subject: [DB-SIG] Oracle tables encapsulation
Sender: db-sig-admin@python.org
Errors-To: db-sig-admin@python.org
X-BeenThere: db-sig@python.org
X-Mailman-Version: 1.2 (experimental)
Precedence: bulk
List-Id: SIG on Python Tabular Databases <db-sig.python.org>

----------