We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d0668cc commit f5f05d1Copy full SHA for f5f05d1
README.md
@@ -63,6 +63,21 @@ class Query(graphene.ObjectType):
63
schema = graphene.Schema(query=Query)
64
```
65
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
81
Then you can simply query the schema:
82
83
```python
0 commit comments