简体   繁体   中英

sqlalchemy declarative_base() schema_name not working

I'm creating SQLAlchemy objects for MSSQL via sub-classing declarative_base(). When shifting from in-memory sqlite to production on MSSQL a try and specify the correct MS 'schema' with:

create_engine(config.DB, schema_name='myschema', echo=False)

however the sql emitted is does not include this schema in the query. Am i doing something wrong? All is working great with sqlite in-memory.

answered by ThiefMaster on freenode #sqlalchemy

if you set the schema directly on the object then it works:

__table_args__ = {'schema': 'myschema'} 

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