ido klein
ido klein

Reputation: 135

activating spatialite when calling sqlite3 on a gpkg from power query

I'm trying to make a spatial query on a table with a geometry column, stored in a gpkg, through excel's power query. when trying to run the query, as such:

= Odbc.Query("database=path/to/gpkg;dsn=SQLite3 Datasource", "select *,st_centroid(geom) as cent from some_layer")

it returns the following error:

DataSource.Error: ODBC: ERROR [HY000] no such function: st_centroid (1)

The following happens also when running from sqlite3 cli: enter image description here

however, if I run

select load_extension('mod_spatialite')

beforehand, it works.

My problem is that when I try to run two commands in power query, like so:

= Odbc.Query("database=path/to/gpkg;dsn=SQLite3 Datasource", "select load_extension('mod_spatialite');#(lf)select * from some_layer")

I get the following error:

DataSource.Error: ODBC: ERROR [HY000] only one SQL statement allowed

so my question is - how can one setup a call to sqlite3 where the spatialite extension is already loaded?

Upvotes: 2

Views: 269

Answers (0)

Related Questions