Skip to content

Commit 3f50a4c

Browse files
authored
Merge branch 'master' into association_proxy-support
2 parents 7fd8d29 + f5f05d1 commit 3f50a4c

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

Diff for: README.md

+15
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,21 @@ class Query(graphene.ObjectType):
6363
schema = graphene.Schema(query=Query)
6464
```
6565

66+
We need a database session first:
67+
68+
```python
69+
from sqlalchemy import (create_engine)
70+
from sqlalchemy.orm import (scoped_session, sessionmaker)
71+
72+
engine = create_engine('sqlite:///database.sqlite3', convert_unicode=True)
73+
db_session = scoped_session(sessionmaker(autocommit=False,
74+
autoflush=False,
75+
bind=engine))
76+
# We will need this for querying, Graphene extracts the session from the base.
77+
# Alternatively it can be provided in the GraphQLResolveInfo.context dictionary under context["session"]
78+
Base.query = db_session.query_property()
79+
```
80+
6681
Then you can simply query the schema:
6782

6883
```python

0 commit comments

Comments
 (0)