Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/298.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用SqlAlchemy创建群集列存储索引(MS SQL Server)?_Python_Sql Server_Database_Orm_Sqlalchemy - Fatal编程技术网

Python 使用SqlAlchemy创建群集列存储索引(MS SQL Server)?

Python 使用SqlAlchemy创建群集列存储索引(MS SQL Server)?,python,sql-server,database,orm,sqlalchemy,Python,Sql Server,Database,Orm,Sqlalchemy,如何使用SqlAlchemy python库在表上创建集群列存储索引 我可以在文档中看到对聚集索引的支持,但找不到如何向其中添加columnstore关键字 您可以通过在创建事件后收听表并注入一些自定义SQL来解决此问题: engine=sqlalchemy.create_引擎(…) 元数据=元数据(引擎) 表=学生=表( “学生”,元数据, 列('id',整数), 列('name',字符串(100)),#必须为固定长度! 列('lastname',字符串(100)), ) 听我说( 桌子 “创

如何使用SqlAlchemy python库在表上创建集群列存储索引


我可以在文档中看到对聚集索引的支持,但找不到如何向其中添加columnstore关键字

您可以通过在创建事件后收听表
并注入一些自定义SQL来解决此问题:

engine=sqlalchemy.create_引擎(…)
元数据=元数据(引擎)
表=学生=表(
“学生”,元数据,
列('id',整数),
列('name',字符串(100)),#必须为固定长度!
列('lastname',字符串(100)),
)
听我说(
桌子
“创建后”,
DDL(“在%(全名)s上创建聚集的列存储索引ix_u%(表)s_u列存储”)
)
table.create()


sqlalchemy允许您注入自定义SQL处理程序,因此这应该可以:

#为索引创建自定义mssql_columnstore参数:
用于(“mssql”、“columnstore”和“无”)的Index.argument_
#用于列存储索引的自定义SQL生成器
@编译(CreateIndex,“mssql”)
def compile_create_索引(创建,编译器,**kw):
preparer=compiler.preparer
mssql_opts=create.element.dialogue_选项[“mssql”]
columnstore=mssql_opts.get(“columnstore”,无)
如果(不是columnstore):
stmt=编译器。访问创建索引(创建,**kw)
返回stmt
name=preparer.format\u索引(create.element)
table\u name=preparer.format\u table(create.element.table)
stmt=f“在{table_name}上创建聚集列存储索引{name}”
返回stmt
engine=makeEngine()
元数据=元数据(引擎)
表=学生=表(
“学生”,元数据,
列('id',整数),
列('name',字符串(100)),
列('lastname',字符串(100)),
#在此处使用columnstore索引标志:
索引('idx_id',mssql_columnstore=True),
)
table.create()

目前还不支持columnstore,这对我来说也是一件痛苦的事情,当使用columnstore连接数据库重建索引时,API堆栈会使应用程序崩溃