File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,21 @@ class Query(graphene.ObjectType):
63
63
schema = graphene.Schema(query = Query)
64
64
```
65
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
+
66
81
Then you can simply query the schema:
67
82
68
83
``` python
You can’t perform that action at this time.
0 commit comments