Codebase list python-graphene-sqlalchemy / upstream/2.0.0 docs / tips.rst
upstream/2.0.0

Tree @upstream/2.0.0 (Download .tar.gz)

tips.rst @upstream/2.0.0view markup · raw · history · blame

Tips

Tips

System Message: INFO/1 (<string>, line 6); backlink

Duplicate implicit target name: "tips".

Querying

For make querying to the database work, there are two alternatives:

  • Set the db session when you do the execution:
schema = graphene.Schema()
schema.execute(context_value={'session': session})
  • Create a query for the models.
Base = declarative_base()
Base.query = db_session.query_property()

class MyModel(Base):
    # ...

If you don't specify any, the following error will be displayed:

A query in the model Base or a session in the schema is required for querying.