Lukasz Szybalski ha scritto:
Got another error here. but I guess its fixed in a newer version of
sqlalchemy via ticket 482
Yes. I wasn't aware of 482 because I usually try to avoid table names
that _must_ be escaped (mixed caps, reserved words, etc).
put assign_mapper() in place of
Lukasz Szybalski ha scritto:
bind_meta_data()
users_table = Table('users', metadata, autoload=True)
class Users(object):
pass
usersmapper=mapper(Users,users_table)
assign_mapper() in place of mapper()
mysession=session.query(Users)
1. What would be the code from now on to
hello -
you generally use mapper() and relation() to set up how you'd like
your classes to correspond to your table relationships. as far as
compound keys, if they are defined with a primary key constraint you
shouldn't have to worry about them.
---
Ok. So we are using mapper()
ok...correct me if I'm wrong.
#we start by importing
from turbogears.database import metadata, session,bind_meta_data
from sqlalchemy.ext.assignmapper import assign_mapper
from turbogears import widgets, validators
import sqlalchemy
#Then we bound to database
bind_meta_data()
#create a table