SQL2Python

Jude Venn jude.venn at ntlworld.com
Wed Aug 2 17:53:45 EDT 2000


I have been planning a similar thing myself, though my motives are aimed
more towards transparently persisting objects without worrying about where
they go or in what format. I am considering using a seperate file (most
likely xml) to map objects and their properties to bits of SQL. A seperate
object would handle reading and writing all other objects based on the
external map file.
Any thoughts welcomed,

Jude

Gerhard Haering <haering at sunhalle3.informatik.tu-muenchen.de> wrote in
message news:slrn8oh3k3.q1h.haering at sunhalle3.informatik.tu-muenchen.de...
> Hi!
>
> Like you, I am currently investigating ways to simplify database
> programming via a an object-oriented interface.
>
> I have found a few related Python modules, but none are quite satisfying
> for me, yet:
>
> http://starship.python.net/~amk/python/unmaintained/ordb.html
>   (beginnings of an object-relational mapper)
> http://starship.python.net/crew/adustman/ (SQLdict)
> http://zdc.sourceforge.net/ (zike data classes)
>
> The interesting question is IMO how to create the Python classes from SQL.
> - from a Database Definition Language file (is there any standardized file
>   format for entity relationship diagrams?)
> - from database queries (I think I could get all relationships from an
>   Oracle databse, but MySQL is once again out of game: no foreign keys)
>
> One problem is also database versioning: I don't want to have to recreate
> the database and Python classes every time I add a field.
>
> If you find the Holy Grail I'd like to hear from you :-)
>
> Gerhard
>
> In article <3987DD9C.95A279C7 at sympatico.ca>, vio wrote:
> >Greetings,
> >
> >Has anyone attempted to "port" an SQL script to Python ?
> >
> >I have an ANSI-SQL script which creates a 200 tables database. Since
> >tables seem to make excellent candidates for "objects", I want to port
> >my SQL code to Python, which is much more flexible than SQL. Mapping SQL
> >to Py might look something like this:
> >
> >SQL Table    ->    Python Class
> >Table columns    ->    Class attributes
> >Table rows    ->    Class instantiations (objects)
> >Table Index    ->    Class Dictionary
> >Primary Keys    ->    Dictionary Keys
> >Foreign Keys    ->    reference to other class' Dictionary Keys
> >
> >
> >I guess my question is if anyone is aware of already written SQL2Python
> >"mapping/porting" script. Could Gadfly (the Py-written db engine) be of
> >any use for my purpose ?
> >
> >Regards,
> >vio
> >
> >





More information about the Python-list mailing list