简体   繁体   English

sqlalchemy declarative_base()schema_name无法正常工作

[英]sqlalchemy declarative_base() schema_name not working

I'm creating SQLAlchemy objects for MSSQL via sub-classing declarative_base(). 我正在通过子类化declarative_base()为MSSQL创建SQLAlchemy对象。 When shifting from in-memory sqlite to production on MSSQL a try and specify the correct MS 'schema' with: 当从内存中的sqlite转移到MSSQL上的生产时,尝试并使用以下命令指定正确的MS'模式':

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

however the sql emitted is does not include this schema in the query. 但是,发出的sql在查询中不包含此模式。 Am i doing something wrong? 难道我做错了什么? All is working great with sqlite in-memory. 一切都在sqlite内存中很好用。

answered by ThiefMaster on freenode #sqlalchemy 由ThiefMaster回答freenode #sqlalchemy

if you set the schema directly on the object then it works: 如果直接在对象上设置架构,那么它可以工作:

__table_args__ = {'schema': 'myschema'} 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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