问题描述
昨天有人告诉我,如果我想使用Sqlalchemy,Geoalchemy是支持空间扩展的不错选择.真的很好.非常感谢他.
Yesterday someone told me that Geoalchemy was a good choice to support spatial extensions if I want to use Sqlalchemy. It really did good. Thanks for him a lot.
但是我还没有找到使用Geoalchemy创建空间索引的便捷方法.我必须直接运行此SQL吗?
But I have not found a convenient way to create spatial index with Geoalchemy. Must I run this SQL directly?
CREATE SPATIAL INDEX sp_index ON my_class (
geom_col
);
是否有一种简便的方法可以直接进行SQL编写?
Is there a convenient way to do it without directly writing the SQL?
谢谢!
推荐答案
使用table.create()
创建表时,GeoAlchemy将自动为几何列创建索引.
When creating a table with table.create()
GeoAlchemy will automatically create an index for the geometry column.
此外,SQLAlchemy Index
实例具有create
方法.请参见 http://docs.sqlalchemy中的索引"部分. org/en/rel_0_7/core/schema.html#metadata-constraints .我不确定您是否能够以此在MySQL中创建空间索引,但这值得一试.
Also, SQLAlchemy Index
instances have a create
method. See the "Indexes" section in http://docs.sqlalchemy.org/en/rel_0_7/core/schema.html#metadata-constraints. I'm not sure if you'll be able to create a spatial index in MySQL with that but it's worth a try.
这篇关于是否有使用Sqlalchemy或Geoalchemy创建空间索引的便捷方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!