Are there any Python object-relational mapping libraries that, given a database schema, can generate a set of Python classes? I know that the major libraries such as SQLObject, SQLAlchemy, and Django's internal SQL ORM library do a very good job of creating a DB schema given a set of classes, but I'm looking for a library that works in reverse.
There is a related question for Perl libraries on Stack Overflow.
-
SQLAlchemy extension to create a python code model from an existing database
-
Geniusql (and Dejavu, its big federated brother) can do that quite well. See "Automatic Table Classes" for the former and "Automatic Unit Classes" for the latter.
-
Django had an inspectdb command that creates models.py files out of your database.
-
SQLAlchemy can actually do what you want. You can either define the mappings yourself manually using the mapper facility, or auto-generate them using reflection.
It's not absolutely necessary to build the database using the metadata facility, you can always use an existing one instead.
0 comments:
Post a Comment