该类MapperExtension
有一些方法,并且before_insert
, before_update
, ... 都有一个参数connection
。
def before_insert(self, mapper, connection, instance):
我已经阅读了 的文件MapperExtension
,但没有发现任何关于此的内容connection
。它是什么?以及如何使用它?
该类MapperExtension
有一些方法,并且before_insert
, before_update
, ... 都有一个参数connection
。
def before_insert(self, mapper, connection, instance):
我已经阅读了 的文件MapperExtension
,但没有发现任何关于此的内容connection
。它是什么?以及如何使用它?
Connection
它是class的一个实例。最新版本的 SQLAlchemy 发行版有示例目录,请参阅示例/nested_sets/nested_sets.py以了解如何在映射器扩展中使用它。