这个也与spatilite有关(不仅仅是SQLite)
我有一个文件数据库(xyz.db)我正在使用SQLiteconnection(SQLiteconnection扩展到spatialite).
我有这么多记录需要更新到数据库中.
for (int y = 0; y < castarraylist.Count; y++)
{
string s = Convert.ToString(castarraylist[y]);
string[] h = s.Split(':');
SQLiteCommand sqlqctSQL4 = new SQLiteCommand("UPDATE temp2 SET GEOM = " + h[0] + "WHERE " + dtsqlquery2.Columns[0] + "=" + h[1] + "", con);
sqlqctSQL4.ExecuteNonQuery();
x = x + 1;
}
Run Code Online (Sandbox Code Playgroud)
在上面的逻辑castarraylist是Arraylist其中包含的值需要加工成数据库.
当我检查上面的代码时,在1分钟内更新大约400条记录.
有什么方法可以提高性能吗?
NOTE ::(文件数据库不是线程安全的)
2.开始交易
假设我想在Spatialite中使用单个事务运行两个(或数百万个)更新语句..是否可能?
我在线阅读并为我准备以下声明(但没有获得成功)
BEGIN TRANSACTION;
UPDATE builtuparea_luxbel SET ADMIN_LEVEL = 6 …Run Code Online (Sandbox Code Playgroud) 我在OS X Yosemite上安装Spatialite工具时遇到问题,首先我在OS X上阅读了安装Spatialite for python(GeoDjango),但它没有帮我解决问题.
在这里,我将提供一些步骤,以便使用Homebrew安装spatialite.
1)安装最新的sqlite3
brew install sqlite
==> Downloading https://homebrew.bintray.com/bottles/sqlite-3.8.8.3.yosemite.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/sqlite-3.8.8.3.yosemite.bottle.tar.gz
==> Pouring sqlite-3.8.8.3.yosemite.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local.
Mac OS X already provides this software and installing another version in
parallel can cause all kinds of trouble.
OS X provides an older sqlite3.
Generally there are no consequences of this for you. If you build your
own software and it requires this …Run Code Online (Sandbox Code Playgroud) 我正在通过空间表中的SQL查询创建一个新表:
CREATE TABLE SomeShapes AS
SELECT ash.id, ash.Geometry
FROM AllShapes ash
WHERE ash.id = 30
Run Code Online (Sandbox Code Playgroud)
但是,这会返回一个"普通"表,因此当我尝试在GIS程序(QGIS)中加载它时,它不会显示几何图形.如何声明几何体列包含几何体?
我在设置GeoDjango安装时仍然遇到问题,该安装使用Spatialite作为Windows机器的后端.
我使用了GeoDjango安装程序并从http://www.gaia-gis.it/spatialite/binaries.html下载了预编译库,并将它们转储到我的geodjango/bin目录中.
我将我的pysqlite2安装升级到最新版本,以便可以加载扩展并SPATIALITE_LIBRARY_PATH在我的设置文件中指定.
当我运行时,manage syncdb我得到以下输出
C:\stuff>manage.py syncdb
SpatiaLite version ..: 2.3.1 Supported Extensions:
- 'VirtualShape' [direct Shapefile access]
- 'VirtualText' [direct CSV/TXT access]
- 'VirtualNetwork [Dijkstra shortest path]
- 'RTree' [Spatial Index - R*Tree]
- 'MbrCache' [Spatial Index - MBR cache]
- 'VirtualFDO' [FDO-OGR interoperability]
- 'SpatiaLite' [Spatial SQL - OGC]
PROJ.4 Rel. 4.6.1, 21 August 2008
GEOS version 3.0.2-CAPI-1.4.2
但是,在为表设置索引时,我收到以下消息:
... Installing custom SQL for core.LocationHint model updateTableTriggers: "no such module: rtree" …
我是新来的,这是我的第一个主题.我是iOS平台上的新手,我正在尝试使用sqlite3进行空间扩展,但我无法做到这一点.这让我发疯了.我不知道我该怎么做,从哪里开始.有人可以给我一些建议吗?
谢谢.
根据https://docs.djangoproject.com/en/1.3/ref/contrib/gis/db-api/,Spatialite支持GeoQuerySet.distance().但是,导入区域列表(MultiPolygon作为mpoly属性)后,我正在尝试执行以下操作:
Area.objects.all().distance(center)
Run Code Online (Sandbox Code Playgroud)
而不是可用的东西,我只收到一条错误消息:" ValueError:SQLite不支持大地坐标系上的线性距离计算. "
这里有什么问题,我是否需要在Spatialite上进行一些特殊配置或文档是否错误?
我正在尝试让 Spatialite 与我的 django 应用程序一起使用,但是,我遇到了以下问题:
raise ImproperlyConfigured('The pysqlite library does not support C extension loading. '
django.core.exceptions.ImproperlyConfigured: The pysqlite library does not support C extension loading. Both SQLite and pysqlite must be configured to allow the loading of extensions to use SpatiaLite.
make: *** [syncdb] Error 1
Run Code Online (Sandbox Code Playgroud)
使用 ubuntu 12.04,我已经安装了 pysqlite pip,在同一个用户中使用 sudo。我也尝试过编译 pysqlite 并启用扩展加载自己。
帮助?
我试图spatialite在Windows 7上同时使用Python 2和3.
而不是试图修补pyspatialite的Python 3,我决定用load_extension与方法sqlite3Python的内置包,类似于这里是如何做的:sqlite的load_extension在Python失败spatialite这里:使用spatialite扩展SQLite的Windows上.
但是,在官方(C)Python 2.7安装程序上,load_extension已针对与MacOS相关的问题禁用了该安装程序.这与Python 3.4的对应物不同.此外,两个安装程序都是在没有SQLITE_ENABLE_RTREE=1(我也想拥有)的情况下构建的.
首先,对于Python 2.7,一种解决方法是构建pysqlite调整安装文件以同时拥有R*Tree和扩展.这种方式不适用于Python 3,因为它似乎不受当前支持setup.py.据我所知,这是因为包移到了核心Python存储库:https://github.com/ghaering/pysqlite/issues/72#issuecomment-94319589
我目前的解决方案是使用所需的sqlite3包设置重新构建Python 2.7和3.4 .它工作,我能够加载spatialite作为扩展并创建R*树.
它是否存在替代的更简单的解决方案?难道有人找到对工作的替代解决方案setup.py的pyspatialite还是pysqlite?
我spatialite为Django项目安装了,但是当我尝试迁移时它向我显示此错误:
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/contrib/gis/db/backends/spatialite/base.py", line 44, in get_new_connection
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: SpatiaLite requires SQLite to be configured to allow extension loading.
Run Code Online (Sandbox Code Playgroud)
我不知道如何弄清楚。我 通过更改 libexec/setuptools/setup.cfg 文件来尝试此操作
[build_ext]
#define=
include_dirs=/Library/Frameworks/SQLite3.framework/unix/include
library_dirs=/Library/Frameworks/SQLite3.framework/unix/lib
libraries=sqlite3
#define=SQLITE_OMIT_LOAD_EXTENSION
Run Code Online (Sandbox Code Playgroud)
我已经通过brew安装了spatialite,然后我像这样更改了settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.spatialite',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
SPATIALITE_LIBRARY_PATH='/usr/local/lib/mod_spatialite.dylib'
Run Code Online (Sandbox Code Playgroud) spatialite ×10
sqlite ×6
django ×4
geodjango ×2
python ×2
android ×1
android-ndk ×1
c# ×1
geometry ×1
iphone ×1
macos ×1
osx-yosemite ×1
postgis ×1
python-2.7 ×1
python-3.x ×1
sql ×1