Unidac SQLite create - feature not supported

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
bluewwol
Posts: 5
Joined: Tue 10 Apr 2012 19:01
Location: Hollywood, Florida

Unidac SQLite create - feature not supported

Post by bluewwol » Wed 24 Aug 2022 17:07

Hi,

I have a very frustrating issue trying to create a new SQLite db. when I run this code

Code: Select all

procedure TdmMain.DataModuleCreate(Sender: TObject);
var
  UniConnection: TUniConnection;
begin
  UniConnection := TUniConnection.Create(nil);
  try
    try
      UniConnection.ProviderName := 'SQLite';
      UniConnection.Database := 'C:\DevNew\Trader\test.db';
      UniConnection.SpecificOptions.Values['Direct'] := 'True';
      UniConnection.SpecificOptions.Values['ForceCreateDatabase'] := 'True';

      UniConnection.Connect;
    except
      on E: EXCEPTION do
        dbOk := False;
    end;
  finally
    UniConnection.Free;
  end;
end;
I get this

Code: Select all

ThreadId=1828
ProcessId=3
ThreadName=""
ExceptionMessage="Feature is not supported"
ExceptionName="Exception"
ExceptionDisplayName="Exception"
ExceptionAddress=76CCCA42
FileName=<not available>
LineNumber=<not available>
ExceptionObject=0409EC40
Classes=[Exception,TObject]
Any suggestions would be welcome as I am quite stumped on something so simple
I am using UniDac 9.2.1 Std, from Delphi 11; error occurs in windows 32 bit and 64. My intention is for this to run in Mac, IOS and Android later on too.

-Allen

bluewwol
Posts: 5
Joined: Tue 10 Apr 2012 19:01
Location: Hollywood, Florida

Re: Unidac SQLite create - feature not supported

Post by bluewwol » Wed 24 Aug 2022 20:34

Solved,

The offending piece of code is
UniConnection.SpecificOptions.Values['Direct'] := 'True';
so the question then is when should this be used? In digging through all I can find is this does this just need to be set for the IOS simulator?

Thanks
-Allen

bluewwol
Posts: 5
Joined: Tue 10 Apr 2012 19:01
Location: Hollywood, Florida

Re: Unidac SQLite create - feature not supported

Post by bluewwol » Wed 24 Aug 2022 22:25

for anyone who runs into this in the future here is what I currently have working

Code: Select all

procedure TdmMain.DataModuleCreate(Sender: TObject);
var
  UniConnection: TUniConnection;
  tmpUniQuery: TUniQuery;
begin
  path := GetHomePath + PathDelim{$IFDEF IOS} + 'Documents' + PathDelim{$ENDIF} + 'Quill' + PathDelim;
  ForceDirectories(path);

  UniConnection := TUniConnection.Create(nil);
  tmpUniQuery := TUniQuery.Create(nil);
  tmpUniQuery.Connection := UniConnection;
  scCreate.Connection := UniConnection;
  try
    try
      UniConnection.ProviderName := 'SQLite';
      UniConnection.Database := path + DBName;
      {$IFDEF IOSSIMULATOR}
      UniConnection.SpecificOptions.Values['Direct'] := 'True';
      {$ENDIF}
      UniConnection.SpecificOptions.Values['ForceCreateDatabase'] := 'True';

      UniConnection.Connect;

      tmpUniQuery.SQL.Text := 'SELECT 1 FROM SQLITE_MASTER WHERE UPPER(TYPE) = ''TABLE'' AND UPPER(NAME) = ''CONFIGS''';
      tmpUniQuery.Open;
      if tmpUniQuery.IsEmpty then
      begin
        // DB has not been created yet
        scCreate.Execute;
        dbVer := 1;
      end
      else
      begin
        // Get the DB version from configs
        tmpUniQuery.SQL.Text := 'Select ConfValue from configs where ConfSection = ''DB'' and  ConfItem = ''VER'' ;';
        tmpUniQuery.Open;
        dbVer := tmpUniQuery.FieldByName('ConfValue').AsInteger;
      end;

    except
      on E: EXCEPTION do
        dbOk := False;
    end;
  finally
    tmpUniQuery.Free;
    UniConnection.Free;
  end;
end;

Post Reply