databases.py app.config[' sqlalchemy_database_uri '] = globalsset[' Dblink '] #默认数据库链接 app.config[' Sqlalchemy_bin DS '] = {' One ': globalsset[' dblink_one '], ' both ': globalsset[' dblink_two ']}models.py__tablena me__ = ' tname ' __bind_key__ = ' one '
Problem:
To reuse group BY, you cannot use the distinct notation "db_session.query (table name. IP). Distinct ()" because a multi-data source is used, db_session.query (table name) can only write table names because models in __ Bind_key__ control, I have not found a good way to first use the group_by to weigh so look at the table of the way I just use query (table name) way, has not found a good solution, if the table name is written. field, use the default database link
This article is from the "Intelligent Future _XFICC" blog, please be sure to keep this source http://xficc.blog.51cto.com/1189288/1672887
SQLAlchemy Multi-data source multiple databases