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
import graphene | |
from graphene_sqlalchemy import SQLAlchemyConnectionField, SQLAlchemyObjectType | |
from models import * | |
class Person(SQLAlchemyObjectType): | |
class Meta: | |
model = PersonModel | |
interfaces = (graphene.relay.Node, ) |
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): |
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 create_engine | |
from sqlalchemy.ext.declarative import declarative_base, DeferredReflection | |
from sqlalchemy.orm import scoped_session, sessionmaker | |
connection_string = << your connection string here >> | |
engine = create_engine(connection_string) | |
db_session = scoped_session(sessionmaker(autocommit=False, | |
autoflush=False, | |
bind=engine)) |