首先我创建一个会话如下:
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
some_engine = create_engine('my_engine_string')
Session = sessionmaker(bind=some_engine)
session = Session()
然后我将此会话作为参数发送给方法
def example(session):
print("you created a session!")
是否可以some_engine从方法session内部获取的值example?没有实际传递some_engine或my_engine_string到example方法。
如下:
def example(session):
print("you created a session!")
engine = <using session get the value of `some_engine`>
print("the engine is retrieved from session")
慕尼黑8549860
相关分类