Spatialite是Sqlite的空间数据库扩展。在网上查了些资料,Python目前自带了sqlite模块,操作spatialite需要使用pyspatilite模块。但是在Windows下使用easy_install或者pip直接安装这个模块总是出错。因此参考这里下载配置了spatialite的DLL,然后使用“SELECT load_extension()”加载DLL从而通过python操作spatialite
import sqlite3
# 连接数据库
conn = sqlite3.connect(":memory:")
conn.enable_load_extension(True)
cur = conn.cursor()
# 加载spatialite DLL
cur.execute(r'SEL