Multiple database connections with Python + Pylons + SQLAlchemy

北慕城南 提交于 2019-12-10 23:08:34

问题


I'm trying to implement the proper architecture for multiple databases under Python + Pylons. I can't put everything in the config files since one of the database connections requires the connection info from a previous database connection (sharding).

What's the best way to implement such an infrastructure?


回答1:


Pylons's template configures the database in config/environment.py, probably with the engine_from_config method. It finds all the config settings with a particular prefix and passes them as keyword arguments to create_engine.

You can just replace that with a few calls to sqlalchemy.create_engine() with the per-engine url, and common username, and password from your config file.



来源:https://stackoverflow.com/questions/2205047/multiple-database-connections-with-python-pylons-sqlalchemy

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