如何将空间数据库合并到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

我在空间中只使用简单的点域。没有其他来自Spatialite的东西。(含Lat/液化天然气值)
编辑1:
@科里恩
如果我试着按你的方式做,我不会出错的:
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中内置的扩展。您将需要一个SQLite二进制/库,该库使用静态链接的SpatiaLite构建,或者在导入时加载SpatiaLite动态扩展(请参见链接)。
pgloader manpage开始,您似乎可以预先发送SQL命令,将SpatiaLite扩展加载到SQLite中,如下所示:

pgloader --before load_spatialite.sql  /tmp/db.sqlite3

并且load_spatialite.sql包含
SELECT load_extension('mod_spatialite');

您可能需要也可能不需要设置其他环境变量,以便为您的进程找到动态库。

09-04 09:53