Lukasz Szybalski ha scritto:

> What ever is recommended.  mapper, activemapper, assign_mapper,
> elixir... I wouldn't know the difference between them so I'll use what
> is recommended (mapper()).
>   

assign_mapper on TurboGears. It's using SessionContext.



> Here is my model.py
> from sqlalchemy import *
> from turbogears.database import metadata, session,bind_meta_data
> from sqlalchemy.ext.assignmapper import assign_mapper
> from sqlalchemy.ext.activemapper import *
> from turbogears import widgets, validators
>   

Where does engine come from?
I can't follow much with all those asterisks.

Try "import sqlalchemy as sa", it saves enough typing.

As a rule, I like to be able to say where objects come from, it helps 
immensely.

In this case, engine is the module sqlalchemy.engine

BTW: what are you doing with widgets and validators in your model? Are 
you sure that usage does not belong to controllers or somewhere else 
entirely?


> #Binding metadata to database
> bind_meta_data()
> #Table creation, from database
> tables = []
> for name in engine.execute("SHOW TABLES"):
>     tables[name] = sa.Table(name, metadata, autoload=True)
>
>
> I get an error
>
>     for name in engine.execute("SHOW TABLES"):
> AttributeError: 'module' object has no attribute 'execute'
>   

Sorry, I should have been more explicit:


from turbogears import database

engine = database.get_engine()




--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to