Enable Extension Loading

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQLite in Delphi and C++Builder
Post Reply
Flynn
Posts: 5
Joined: Thu 31 May 2012 16:19

Enable Extension Loading

Post by 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.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Enable Extension Loading

Post by 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

Flynn
Posts: 5
Joined: Thu 31 May 2012 16:19

EnableLoadExtension has no effect in dbExpress driver for SQLite 3.4.6

Post by 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.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Enable Extension Loading

Post by 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.

Flynn
Posts: 5
Joined: Thu 31 May 2012 16:19

Re: Enable Extension Loading

Post by 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-w ... 080500.zip
both functions "enable_load_extension" and "load_extension" are available in this dll and usable with a simple delphi-wrapper (sv-utils).

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Enable Extension Loading

Post by 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")');

Flynn
Posts: 5
Joined: Thu 31 May 2012 16:19

Re: Enable Extension Loading

Post by 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.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Enable Extension Loading

Post by 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.

Flynn
Posts: 5
Joined: Thu 31 May 2012 16:19

Re: Enable Extension Loading

Post by 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 ;-)

Post Reply