Last active
November 17, 2021 17:58
-
-
Save ssomnoremac/406c69dc293d948111f903914063fc1d to your computer and use it in GitHub Desktop.
models for graphene sqlalchemy example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy import Column, Integer, ForeignKey | |
from sqlalchemy.orm import relationship | |
from database import Base | |
class PersonModel(Base): | |
__tablename__ = 'person' | |
uuid = Column(Integer, primary_key=True) | |
Articles = relationship("ArticleModel") | |
class ArticleModel(Base): | |
__tablename__ = 'article' | |
uuid = Column(Integer, primary_key=True) | |
person_id = Column(ForeignKey("person.uuid")) | |
Base.prepare(engine) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
engine is not defined in this snippet, did you intend to import
engine
as well fromdatabase.py
on line 3 ?