[DB-SIG] Oracle tables encapsulation
Olivier BERGER" <email@example.com
Thu, 2 Dec 1999 11:36:00 +0100
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) :
... 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)
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.