什么是sqlalchemy中MapperExtension的`connection`参数? [英] What is the `connection` parameter of MapperExtension in sqlalchemy?

查看:157
本文介绍了什么是sqlalchemy中MapperExtension的`connection`参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MapperExtension 有一些方法, before_insert before_update ,...都有一个参数连接

The class MapperExtension has some methods, and before_insert, before_update, ... all have a parameter connection.

def before_insert(self, mapper, connection, instance):

c $ c> MapperExtension ,但是没有发现这个连接。它是什么?如何使用它?

I've read the documents of MapperExtension, but found nothing about this connection. What is it? And how to use it?

推荐答案

这是 Connection class 。最新版本的SQLAlchemy发行版有示例目录,请参阅 examples / nested_sets / nested_sets.py 来了解如何在mapper扩展中使用它。

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆