sqlalchemy中MapperExtension的`connection`参数是什么? [英] What is the `connection` parameter of MapperExtension in sqlalchemy?
本文介绍了sqlalchemy中MapperExtension的`connection`参数是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
MapperExtension
类有一些方法,before_insert
,before_update
,...都有参数connection
.
The class MapperExtension
has some methods, and before_insert
, before_update
, ... all have a parameter connection
.
def before_insert(self, mapper, connection, instance):
我已经阅读了 MapperExtension
的文档,但是没有找到关于这个 connection
的信息.它是什么?以及如何使用?
I've read the documents of MapperExtension
, but found nothing about this connection
. What is it? And how to use it?
推荐答案
它是 Connection
类.SQLAlchemy 发行版的最新版本有示例目录,请参阅 examples/nested_sets/nested_sets.py 了解如何在映射器扩展中使用它.
It's an instance of Connection
class. Recent versions of SQLAlchemy distribution have examples directory, see examples/nested_sets/nested_sets.py to get an idea on how to use it in mapper extension.
这篇关于sqlalchemy中MapperExtension的`connection`参数是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文