0
在下面的代码,如果我打/ testDbOne我没有错误,如果我打/ testDbTWo我得到以下错误:瓶和SQLAlchemy的多个数据库
TypeError('testDbTwo() takes exactly 1 argument (0 given)',)
如果我换引擎1和引擎2的位置,然后testDbOne打破并且testDbTwo工作。我做错了什么,我不能让SQLAlchemy创建两个会话并将它们作为插件安装到瓶子中?
Base = declarative_base()
#engine1
engine_s = create_engine('mysql://user:[email protected]/dbone', echo=True)
create_session_s = sessionmaker(bind=engine_s)
bottle.install(SQLAlchemyPlugin(engine_s, Base.metadata, keyword="dbone"))
#engine2
engine = create_engine('mysql://user:[email protected]/dbtwo', echo=True)
create_session = sessionmaker(bind=engine)
bottle.install(SQLAlchemyPlugin(engine, Base.metadata, keyword="dbtwo"))
#create the actual database sessions
dboneSession = create_session_s()
dbTwoSession = create_session()
@route("/testDbOne")
def testUserOne(dbone):
return "no error here"
@route("/testDbTwo")
def testDbTwo(dbtwo):
return "no error here"