Yunlong Mao
2014-03-14 05:28:23 UTC
Hi all,
I have some problem with sqlalchemy and mysql.
"""
class User(db.Model, UserMixin):
__tablename__ = 'user'
id = Column(Integer, autoincrement=True, nullable=False, unique=True,
index=True)
coreid = Column(String(32), primary_key=True)
"""
u_r_association = Table('user_role', db.metadata,
Column('id', Integer, primary_key=True),
Column('user_id', Integer, ForeignKey('user.id'), nullable=False),
Column('role_id', Integer, ForeignKey('role.id'), nullable=False)
)
I create model and association table like this, my problems:
1. the autoincrement is invalid, i can't find it after create sql by
sqlachemy.
2. how can i set the autoincrement with a initialize value.
3. how can i not generate the real foreignkey in databases, only leave it
in model config.
thanks.
I have some problem with sqlalchemy and mysql.
"""
class User(db.Model, UserMixin):
__tablename__ = 'user'
id = Column(Integer, autoincrement=True, nullable=False, unique=True,
index=True)
coreid = Column(String(32), primary_key=True)
"""
u_r_association = Table('user_role', db.metadata,
Column('id', Integer, primary_key=True),
Column('user_id', Integer, ForeignKey('user.id'), nullable=False),
Column('role_id', Integer, ForeignKey('role.id'), nullable=False)
)
I create model and association table like this, my problems:
1. the autoincrement is invalid, i can't find it after create sql by
sqlachemy.
2. how can i set the autoincrement with a initialize value.
3. how can i not generate the real foreignkey in databases, only leave it
in model config.
thanks.
--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+***@googlegroups.com.
To post to this group, send email to ***@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.