sqlalchemy calls the behavior you're looking for 'reflecting'
a pylons -- or non-pylons -- approach to handling this might be such
( old sqlalchemy 4 code ):
1. have a 'meta' module, that has code like this:
--------
from model import *
engine = sqlalchemy.create_engine('postgres://app:a...@localhost/app')
metadata = sqlalchemy.MetaData(engine)
Books_t= sqlalchemy.Table('books', metadata, autoload=True )
Books_mapper= sqlalchemy.orm.mapper( Books , Books_t )
--------
2. your model classes look like
--------
class Books(object):
pass
--------
In this concept, the meta module sets up the engine and maps the
tables to classes.
And then In your controllers, you'd just import the models.
IIRC, the pylons app templates make this all pretty trivial/automatic
through the env/middleware they generate.
IMHO though, one metadata/engine isn't a good idea. i always set up
separate read/write/log connections both for scaling and for security
( keeping writable db connections away from most pages )
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---