作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
如何将 SpatiaLite 数据库合并到 PostGIS 数据库?
我尝试通过以下命令使用 pgloader:
pgloader db.sqlite3 postgresql:///mydb
但它不起作用。 (我猜它不被支持)。请查看错误输出:
KABOOM!
FATAL error: Could not prepare an sqlite statement.
Code ERROR: no such module: VirtualSpatialIndex.
Database: /tmp/db.sqlite3
SQL: PRAGMA table_info(`SpatialIndex`)
An unhandled error condition has been signalled:
Could not prepare an sqlite statement.
Code ERROR: no such module: VirtualSpatialIndex.
Database: /tmp/db.sqlite3
SQL: PRAGMA table_info(`SpatialIndex`)
FATAL: Failed to start the monitor thread.
error opening #P"/tmp/pgloader/pgloader.log": Permission denied
我在 SpatialLite 中仅使用简单的 POINT 字段。 SpatialLite 没有其他内容。 (有 Lat/Lng 值)
编辑 1:@Corion
如果我尝试按照您的方式进行操作,我不会出错:
pgloader --before load_spatialite.sql db.sqlite3
但是使用此命令将其加载到 PostGIS:
pgloader --before load_spatialite.sql db.sqlite3 postgresql:///mydb
给我以下错误信息:
2018-10-10T11:29:16.056000Z ERROR Database error 42883: function load_extension(unknown) does not exist
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
QUERY: SELECT load_extension('mod_spatialite')
KABOOM!
FATAL error: Database error 42883: function load_extension(unknown) does not exist
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
QUERY: SELECT load_extension('mod_spatialite')
An unhandled error condition has been signalled:
Database error 42883: function load_extension(unknown) does not exist
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
QUERY: SELECT load_extension('mod_spatialite')
What I am doing here?
Database error 42883: function load_extension(unknown) does not exist
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
QUERY: SELECT load_extension('mod_spatialite')
这里有什么问题?
最佳答案
SpatiaLite是 SQLite 内置的扩展。您将需要一个使用静态链接的 SpatiaLite 构建的 SQLite 二进制文件/库,或者在导入时加载 SpatiaLite 动态扩展(参见链接)。
从盯着 pgloader
manpage ,您似乎可以像这样在 SQL 命令前添加 SpatiaLite 扩展以将 SpatiaLite 扩展加载到 SQLite 中:
pgloader --before load_spatialite.sql /tmp/db.sqlite3
和load_spatialite.sql
包含
SELECT load_extension('mod_spatialite');
您可能需要也可能不需要设置额外的环境变量,以便为您的进程找到动态库。
关于postgresql - 如何从 SpatialLite 合并到 PostGIS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52738729/
我是一名优秀的程序员,十分优秀!