Support for SQLite load_extension (e.g. for Spatialite)
Original Reporter info from Mantis: BigChimp
-
Reporter name: Reinier Olislagers
Original Reporter info from Mantis: BigChimp
- Reporter name: Reinier Olislagers
Description:
The SQLite dll supports loading extension libraries (dlls/sos).
The attached patch enables this.
Note: you apparently must have an open database connection for this to work; the patch checks for this.
I intend to use this to load the Spatialite GIS extensions to SQlite, allowing me to manipulate GIS data easily without a client/server database server.
Additional information:
Patch tested on Win x86 FPC only
You can load an extension dll/so as an extension to SQLite, with a statement like [3]
select load_extension('libspatialite-4.dll');
However, before that you have to enable the extension load mechanism
using the C API [2]:
int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
(onoff==1 to turn extension loading on)
[2] http://www.sqlite.org/c3ref/enable_load_extension.html
[3] http://www.sqlite.org/lang_corefunc.html#load_extension
Example use within Lazarus:
DBConnection.DatabaseName:='osm.sqlite';
DBConnection.Open;
DBConnection.LoadExtension('libspatialite-4.dll');
//Note: we need an open db before doing this
Mantis conversion info:
- Mantis ID: 20640
- OS: Windows
- OS Build: Vista
- Build: fixes_2_6, r19599
- Platform: x64
- Version: 2.5.1
- Fixed in revision: 20146 (#89866cd1)
- Monitored by: » BigChimp (Reinier Olislagers)