Skip to content

Instantly share code, notes, and snippets.

@mydreambei-ai
Last active August 10, 2016 07:39
Show Gist options
  • Save mydreambei-ai/8917851cd02d06251faa4efe8d8f5871 to your computer and use it in GitHub Desktop.
Save mydreambei-ai/8917851cd02d06251faa4efe8d8f5871 to your computer and use it in GitHub Desktop.
sqlalchemy declare abstract base
from sqlalchemy.ext.declarative import declared_attr, AbstractConcreteBase
class _Event(AbstractConcreteBase):
@declared_attr
def hackinfo_id(self):
return Column(ForeignKey("hackinfos.id", ondelete='CASCADE'))
@declared_attr
def hackinfo(self):
return relationship("HackInfo")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment