On Apr 7, 2010, at 9:56 PM, 诚子 wrote:

> 
> there
> 
> http://my.unix-center.net/~WeiZhicheng/2010/04/07/the-problem-using-sequence-in-postgresql-via-sqlalchemyuh-a-patch-file/
> 
> is the full detian in my problem.
> 
> now It's work for me,but is there has another good idea?

"default" is a Python-side default.  For a default that is rendered in CREATE 
TABLE, you're looking for "server_default".   Sequence doesn't currently work 
directly with server_default so you need to declare it separately:

s = Sequence('lala_id_seq')
t1 = Table('t1', m, 
    Column('foo', Integer, 
                        primary_key=True, 
                        server_default=text("nextval('lala_id_seq')"), 
                        autoincrement=False)
)

s.create(engine)
m.create_all(engine)

none of this is required if you just use SERIAL, which is the default behavior 
if you don't turn off "autoincrement".


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalch...@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