Access to database

Discussion of open issues, suggestions and bugs regarding LiteDAC (SQLite Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Anske
Posts: 3
Joined: Mon 06 Dec 2021 15:27

Access to database

Post by Anske » Mon 06 Dec 2021 15:37

I created a database with a default TFDConnection (no encryption) the following way.
How can I open this database by using TLiteConnection?

FDConnection1.Connected := False;
FDConnection1.Params.Database := 'testdatabase.db';
FDConnection1.Params.UserName := 'username';
FDConnection1.Params.Password := 'password';
FDConnection1.Connected := True;

when I try it this way:

LiteConnection1.Disconnect;
LiteConnection1.Database:= 'testdatabase.db';
LiteConnection1.Username:= 'username';
LiteConnection1.Password:= 'password';
LiteConnection1.Connect;

I am getting a message " File is not a database"

frickler
Posts: 37
Joined: Wed 04 Apr 2018 08:30

Re: Access to database

Post by frickler » Tue 07 Dec 2021 11:11

Neither FireDAC nor LiteDAC/UniDac use SQLite's own encryption (because it's very expensive). Instead, they have both their own proprietary encryption method, which is incompatible to each other. By providing a password you switch on encryption.

Anske
Posts: 3
Joined: Mon 06 Dec 2021 15:27

Re: Access to database

Post by Anske » Tue 07 Dec 2021 12:17

So this means once created the database the Firedac method with password, I can't open it ever again in case I want to switch to a TLiteConnection? That's a bummer...

Anske
Posts: 3
Joined: Mon 06 Dec 2021 15:27

Re: Access to database

Post by Anske » Thu 09 Dec 2021 16:08

I can use FDSQliteBackup to create a copy of the database without the password and then I can open the copy with a TLiteConnection.
Is it possible to use LiteBackup to create a copy of this copy using the encryption from devart and if yes how?
Can someone point me to an example how TLiteBackup works?

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: Access to database

Post by MaximG » Wed 22 Dec 2021 20:30

You can accomplish that task with our components. For example, the following sample code creates a copy of an encrypted database (LiteConnectionEncrypt) using the TLiteBackup component:

Code: Select all

...
  LiteConnectionEncrypt.Database := 'C:\test.src';
  LiteConnectionEncrypt.Options.EncryptionAlgorithm := leBlowfish;
  LiteConnectionEncrypt.EncryptionKey := '11111';
  LiteConnectionEncrypt.Open;

  LiteConnectionDestination.Database := 'c:\test.dst';
  LiteConnectionDestination.Options.ForceCreateDatabase := True;
  LiteConnectionDestination.Open;

  LiteBackup.SourceConnection := LiteConnectionEncrypt;
  LiteBackup. DestinationConnection := LiteConnectionDestination;
  LiteBackup.Backup;
  ...

Post Reply