gpt4 book ai didi

postgresql - 如何从 SpatialLite 合并到 PostGIS?

转载 作者:行者123 更新时间:2023-11-29 13:12:49 26 4
gpt4 key购买 nike

如何将 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com