Load spatialite extension

86 views
Skip to first unread message

Saeed

unread,
Sep 1, 2017, 11:45:12 PM9/1/17
to SpatiaLite Users

Hi everybody

 

In python there is a function to enablele spatilite:

 

con.enable_load_extension(True)

 

In matlab, there is no such function in "sqlite" object, or I couldn’t find.

 

Is there any chance to enable spatialite extension by using sql statement?

 

thanks in advance

a.fu...@lqt.it

unread,
Sep 2, 2017, 4:45:00 AM9/2/17
to spatiali...@googlegroups.com
On Fri, 1 Sep 2017 20:45:12 -0700 (PDT), Saeed wrote:
> In python there is a function to enablele spatilite:
>
> con.enable_load_extension(True)
>
> In matlab, there is no such function in "sqlite" object, or I
> couldn’t find.
>
> Is there any chance to enable spatialite extension by using sql
> statement?
>

Hi Saeed,

the dynamic extension loading mechanism supported by libsqlite3
is configurable, so it can be influenced by several specific
factors.

1. compile time options: if libsqlite3 has been compiled by
declaring the -DSQLITE_OMIT_LOAD_EXTENSION flag then the
binary code will be completely unable to load dynamic
extensions.
this is not the standard default setting, but sometimes
it's adopted by some distributions.
if this is your case you can do nothing so to circumvent
the issue, if not recompiling by yourself a replacement
copy of libsqlite3 built with more liberal settings.

2. run time options: even when libsqlite3 do effectively
support dynamic extension loading this capability still
continues to be implicitly disabled.
your code must explicitly authorize libsqlite3 to enable
the load extension mechanism after executing an
"enable_load_extension" directive.
this step is implemented in different ways by different
languages/tools: there is no general rule.
some packages simply expose the standard sqlite's
"enable_load_extension" call, others could implicitly
enable (or even disable) this option without requiring
any specific user action.
you should carefully check the documentation for
every single package, may be asking the respective
developers or maintainers for further clarifications.

3. it's usually expected that "SELECT load_extension()"
should adopt the standard platform searching rules
for locating the dynamic module to be loaded (DLL
on Windows, shared-lib on Linux or whatever else),
but there are some exceptions to this general rule.
AFAIK the PHP sqlite connector strictly requires
that all extension modules should be located in
some specific directory within the PHP tree.
once again, the general rule has many exceptions:
carefully read the documentation for each individual
package, and try asking developers or maintainers
for any useful information.

4. sometimes (but not always) it could help passing
to "SELECT load_extension()" a full pathname, so
to completely skip the standard searching rules,
as e.g.:
SELECT load_extension("C:/mydir/libs/mod_spatialite.dll');

bye sandro
Reply all
Reply to author
Forward
0 new messages