Quantcast

Extension Loading

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Extension Loading

greenf
Hi
I'm using System.Data.SQLite Nuget package and attempting to load an
extension.
All depenent libraries are in the bin\debug output directory.
Extension is 32 bit and the project is set to compile for 32 bit


Using

conn.EnableExtensions(true);    (I think this is enabled by default)
conn.LoadExtension("mod_spatialite");

works fine, but I need to use the SQL function
 and

conn.EnableExtensions(true);
SQLiteCommand cmd = *conn.Create*Command();
cmd.CommandText = @"SELECT load_extension('mod_spatialite');");
int i = cmd.ExecuteNonQuery();

raises

System.Data.SQLite.SQLiteException : SQL logic error or missing database
not authorized

but I am able to successfully call the function in the SQLite CLI

Could someone point out where I'm going wrong with this syntax please

Thanks
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Extension Loading

Clemens Ladisch
Green Fields wrote:

> conn.EnableExtensions(true);
> conn.LoadExtension("mod_spatialite");
>
> works fine, but I need to use the SQL function
>
> conn.EnableExtensions(true);
> cmd.CommandText = @"SELECT load_extension('mod_spatialite');");
> int i = cmd.ExecuteNonQuery();
>
> raises
>
> System.Data.SQLite.SQLiteException : SQL logic error or missing database
> not authorized

The documentation for sqlite3_enable_load_extension() says:
> This interface enables or disables both the C-API
> sqlite3_load_extension() and the SQL function load_extension(). Use
> sqlite3_db_config(db,SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION,..) to
> enable or disable only the C-API.
<http://www.sqlite.org/c3ref/enable_load_extension.html>

EnableExtensions() call sqlite3_db_config() and not
sqlite3_enable_load_extension().  Apparently, forbidding loading
extensions from SQL is done on purpose.


You could create a user-defined function to call LoadExtension(), but
why do you need to do this from SQL?


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Extension Loading

greenf
In reply to this post by greenf
>You could create a user-defined function to call LoadExtension(), but
>why do you need to do this from SQL?

A good question, but I am attempting to use a different .Net wrapper for
this project which has not imported sqlite3_enable_load_extension().
The simplest thing would be to import the function myself -  except that I
don't have the C skills to translate the arguments to .Net compatibility.

Your reference and comments re the sql function being disabled is something
I hadn't fully understood. I can see that the library has been compiled with
 ENABLE_LOAD_EXTENSION
<http://www.sqlite.org/c3ref/c_dbconfig_enable_fkey.html> so I guess that
means sql is disabled.
I might have to rethink how I approach this then. Perhaps have another look
at importing the function

Thanks for the help
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Loading...