SQLAlchemy Multi-data source multiple databases

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.