简体   繁体   English

如何使用SQLAlchemy从graphQL获取已编译的原始sql?

[英]How to get the compiled raw sql from graphQL with SQLAlchemy?

How to get the compiled raw sql command from the graphQL with SQLAlchemy ? 如何使用SQLAlchemygraphQL获取已编译的原始sql命令? I did the search but no luck :( 我做了搜索,但没有运气:(

schema.py

class RecordType(SQLAlchemyObjectType):

    class Meta:
        model = Record
        interfaces = (graphene.relay.Node, )

class Query(graphene.ObjectType):

    node = graphene.relay.Node.Field()
    record = graphene.Field(RecordType, id=graphene.Int())

    def resolve_record(self, info, **args):
        id = args.get('id')
        return RecordType.get_query(info).get(id)

schema = graphene.Schema(query=Query, types=[RecordType])

Well, I just found the way, reference from https://stackoverflow.com/a/36141722/9041712 好吧,我刚刚找到了方法,参考https://stackoverflow.com/a/36141722/9041712

query = RecordType.get_query(info)
print(query.statement.compile(compile_kwargs={"literal_binds": True}))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM