> What are the advantages of using declarative way of setting table
> definitions? vs
> addressbook_table = sqlalchemy.Table("Addressbook", metadata,
>    sqlalchemy.Column('Address_Sid', sqlalchemy.Integer, primary_key=True),
>    sqlalchemy.Column('FirstName', sqlalchemy.Unicode(40),nullable=False),
> ....
>
> class Addressbook(object):
>    def __init__(self, **kw):
>        """automatically mapping attributes"""
>        for key, value in kw.iteritems():
>            setattr(self, key, value)
>
> mapper(Addressbook, addressbook_table)
>
>
>
> It seems to me as its harder to find information on proper syntax then
> it is with regular table, py object, mapper?
>
> Lucas
>
>
The declarative is a more concise all-in-one style

class Addressbook(Base):
    __tablename__ = "Addressbook"
    Address_Sid = sqlalchemy.Column(sqlalchemy.Integer, primary_key=True)
    FirstName = sqlalchemy.Column(sqlalchemy.Unicode(40),nullable=False)

accomplishes the same thing as the table + class + mapper example including
a default __init__() that accepts keywords for column values.

I do agree that the examples for declarative need to be more comprehensive.
I find it sometimes difficult to translate the mapper style into
declarative, but I'm getting better at it.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to