What is the `connection` parameter of MapperExtension in sqlalchemy?

℡╲_俬逩灬. 提交于 2019-12-10 10:38:09

问题


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

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

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


回答1:


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.



来源:https://stackoverflow.com/questions/3646773/what-is-the-connection-parameter-of-mapperextension-in-sqlalchemy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!