diff --git a/README.md b/README.md index 29da89d..4e61f96 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,21 @@ class Query(graphene.ObjectType): schema = graphene.Schema(query=Query) ``` +We need a database session first: + +```python +from sqlalchemy import (create_engine) +from sqlalchemy.orm import (scoped_session, sessionmaker) + +engine = create_engine('sqlite:///database.sqlite3', convert_unicode=True) +db_session = scoped_session(sessionmaker(autocommit=False, + autoflush=False, + bind=engine)) +# We will need this for querying, Graphene extracts the session from the base. +# Alternatively it can be provided in the GraphQLResolveInfo.context dictionary under context["session"] +Base.query = db_session.query_property() +``` + Then you can simply query the schema: ```python