简体   繁体   中英

mapping one class to two tables from different database in SQLAlchemy

I want to make a management script which read a lot from slave db, surely replicated from master, and write sometimes into master db. Tables that I'm accessing are the same. one from slave, and one from master. So I'd like to use just one mapping class for both of them. how can I map this class to two tables from different databases?

It sounds like you might be interested in database routing. There is a master/slave example on this page:

https://docs.djangoproject.com/en/dev/topics/db/multi-db/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM