Enable Extension Loading

Enable Extension Loading

Postby Flynn » Thu 31 May 2012 16:32

Is there a way to enable extension loading?
Maybe an additional ConnectionParam or something similar?
I've tried "EnableLoadExtension=True" - this doesnt work.
Flynn
 
Posts: 5
Joined: Thu 31 May 2012 16:19

Re: Enable Extension Loading

Postby AlexP » Fri 01 Jun 2012 15:55

Hello,

At the moment this feature is not supported. We will try to add it in the next version of the product
AlexP
Devart Team
 
Posts: 5528
Joined: Tue 10 Aug 2010 11:35

EnableLoadExtension has no effect in dbExpress driver for SQLite 3.4.6

Postby Flynn » Thu 07 Aug 2014 13:36

Code: Select all
SELECT load_extension("libspatialite-2.dll")

Throws a "not authorized" Error, using a full path neither works.

**EDIT: DirectMode seems to do the Job.
Flynn
 
Posts: 5
Joined: Thu 31 May 2012 16:19

Re: Enable Extension Loading

Postby AlexP » Fri 08 Aug 2014 08:03

If the problem occurs only while using an external library, it means that the library was compiled without using the ENABLE_LOAD_EXTENSION compilation option. This option allows you to work with external libraries.
AlexP
Devart Team
 
Posts: 5528
Joined: Tue 10 Aug 2010 11:35

Re: Enable Extension Loading

Postby Flynn » Fri 08 Aug 2014 10:00

i've tried it with the latest stable precompiled binary from the SQLite Download Page:
http://www.sqlite.org/2014/sqlite-dll-win32-x86-3080500.zip
both functions "enable_load_extension" and "load_extension" are available in this dll and usable with a simple delphi-wrapper (sv-utils).
Flynn
 
Posts: 5
Joined: Thu 31 May 2012 16:19

Re: Enable Extension Loading

Postby AlexP » Fri 08 Aug 2014 11:17

To use the extensions, you should set the EnableLoadExtension property to True:

Code: Select all
 
  LiteConnection1.Options.EnableLoadExtension := true;
  LiteConnection1.ExecSQL('SELECT load_extension("libspatialite-2.dll")');
AlexP
Devart Team
 
Posts: 5528
Joined: Tue 10 Aug 2010 11:35

Re: Enable Extension Loading

Postby Flynn » Fri 08 Aug 2014 13:53

this is a working code-snippet on how i create an empty spatialite-db:
Code: Select all
  SQLCon := TSQLConnection.Create(nil);
  with SQLCon do
  begin
    Name := 'SQLCon';
    ConnectionName := 'Devart SQLite Direct';
    DriverName := 'DevartSQLiteDirect';
    GetDriverFunc := 'getSQLDriverSQLiteDirect';
    LoginPrompt := False;
    Params.Clear;
    Params.Add('Database=.\tmp.db');
    Params.Add('EnableLoadExtension=True');
    Params.Add('ForceCreateDatabase=True');
    Open;
    ExecuteDirect('SELECT load_extension ("mod_spatialite");');
    ExecuteDirect('SELECT InitSpatialMetaData();');
    Close;
    Free;
  end;

this one throws the "not authorized" error:
Code: Select all
  SQLCon := TSQLConnection.Create(nil);
  with SQLCon do
  begin
    Name := 'SQLCon';
    ConnectionName := 'Devart SQLite';
    DriverName := 'DevartSQLite';
    GetDriverFunc := 'getSQLDriverSQLite';
    LoginPrompt := False;
    Params.Clear;
    Params.Add('Database=.\tmp.db');
    Params.Add('EnableLoadExtension=True');
    Params.Add('ForceCreateDatabase=True');
    VendorLib := '.\sqlite3.dll';
    Open;
    ExecuteDirect('SELECT load_extension ("mod_spatialite");');
    ExecuteDirect('SELECT InitSpatialMetaData();');
    Close;
    Free;
  end;

all required sqlite- and spatialite- dll's (including dependencies) are in the folder of my executable.
i'm still using my sv-utils-wrapper to handle my geospatial databases with delphi. and i remember that i had to change the "onoff"-parameter of the function "enable_load_extension" from boolean to integer to get it work.
maybe a similar problem here.

anyways ;-) directmode is okay for me - i'll continue playin around with the trial.
Flynn
 
Posts: 5
Joined: Thu 31 May 2012 16:19

Re: Enable Extension Loading

Postby AlexP » Fri 08 Aug 2014 15:05

Thank you for the information. We have reproduced and fixed the problem. This fix will be included to the next build.
AlexP
Devart Team
 
Posts: 5528
Joined: Tue 10 Aug 2010 11:35

Re: Enable Extension Loading

Postby Flynn » Mon 11 Aug 2014 08:18

AlexP wrote:Thank you for the information. We have reproduced and fixed the problem. This fix will be included to the next build.

THX ;-)
Flynn
 
Posts: 5
Joined: Thu 31 May 2012 16:19


Return to dbExpress driver for SQLite