Skip to content

Instantly share code, notes, and snippets.

@jneves
Created August 23, 2017 15:36
Show Gist options
  • Save jneves/a5476541fbea35bbd1b8042468d4cbed to your computer and use it in GitHub Desktop.
Save jneves/a5476541fbea35bbd1b8042468d4cbed to your computer and use it in GitHub Desktop.
class User(DeclarativeBase):
__tablename__ = 'sys_user'
user_id = Column(Integer, autoincrement=True, primary_key=True)
email = Column(Unicode(100))
name = Column(Unicode(100))
class UserLog(DeclarativeBase):
__tablename__ = 'sys_user_log'
log_id = Column(Integer, autoincrement=True, primary_key=True)
log_type = Column(Unicode(10), nullable=False)
user_id = Column(Integer, nullable=False, index=True)
user = relation('User',
foreign_keys=[user_id],
primaryjoin='UserLog.user_id == foreign(User.user_id)',
backref=backref('logs'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment