Michael,
Thank you for your quick reply, however I must apologize as I'm a bit
of a SQLAlchemy newbie.
In the app I'm using the tables are setup using DeclarativeBase, so
the mapper() function is confusing me with its need for a class to be
defined as well as a table_name = Table(); and then using table_name
in the mapper call. Is it possible to use mapper() in a
DeclarativeBase setup where your columns are defined inside the class?
For reference, here's the Post class:
class Post(DeclarativeBase):
__tablename__ = 'posts'
def __init__(self, id, user_id, body):
self.id = id
self.user_id = user_id
self.body = body
id = Column(Integer, autoincrement=True, primary_key=True)
user_id = Column(Integer, ForeignKey('users.id'), nullable=False)
body = Column(UnicodeText, nullable=False)
user = relation('User', order_by='Post.id', backref='posts')
comments = relation('Comments')
How would you apply your suggested mapper() call to this type of
setup? Or do I need to switch things to the "more traditional"
approach?
Thanks,
Seth
On Aug 25, 9:45 am, "Michael Bayer" <[email protected]> wrote:
>
> use a recipe almost identical to the second example
> inhttp://www.sqlalchemy.org/docs/05/mappers.html#sql-expressions-as-map...
> . you just need to add a distinct() inside the count().
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" 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/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---