Skip to content

Instantly share code, notes, and snippets.

@ssomnoremac
Last active November 17, 2021 17:58
Show Gist options
  • Save ssomnoremac/406c69dc293d948111f903914063fc1d to your computer and use it in GitHub Desktop.
Save ssomnoremac/406c69dc293d948111f903914063fc1d to your computer and use it in GitHub Desktop.
models for graphene sqlalchemy example
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)
@gbilkhu
Copy link

gbilkhu commented Nov 17, 2021

engine is not defined in this snippet, did you intend to import engine as well from database.py on line 3 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment