开发者

Multiple database connections with Python + Pylons + SQLAlchemy

开发者 https://www.devze.com 2022-12-19 10:50 出处:网络
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

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开发者_C百科 best way to implement such an infrastructure?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消