Page 1 of 1

Access to database

Posted: Mon 06 Dec 2021 15:37
by Anske
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"

Re: Access to database

Posted: Tue 07 Dec 2021 11:11
by frickler
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.

Re: Access to database

Posted: Tue 07 Dec 2021 12:17
by Anske
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...

Re: Access to database

Posted: Thu 09 Dec 2021 16:08
by Anske
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?

Re: Access to database

Posted: Wed 22 Dec 2021 20:30
by MaximG
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;
  ...