Migrating FireDAC Connection to UniDAC

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Claytron
Posts: 1
Joined: Mon 20 Aug 2018 05:28

Migrating FireDAC Connection to UniDAC

Post by Claytron » Mon 20 Aug 2018 06:10

Hi I am trying to migrate from FireDAC to UniDAC and I'm having trouble finding all of the matching options in UniDAC. Below is the code to create the FireDAC connection.

Code: Select all

begin
	result := TFDConnection.Create(nil);

	result.Params.Clear;
	result.Params.Add('DriverID=SQLite');
	result.Params.Add('Database=' + self.DatabaseFullPath);
	result.Params.Add('OpenMode=CreateUTF16');
	result.Params.Add('LockingMode=Normal');
	result.Params.Add('JournalMode=WAL');
	result.Params.Add('Synchronous=Full');
	result.Params.Add('UpdateOptions.LockWait=True');
	result.Params.Add('BusyTimeout=30000');
	result.Params.Add('SQLiteAdvanced=temp_store=MEMORY');
	result.Params.Add('SQLiteAdvanced=page_size=8192');
	result.Params.Add('SQLiteAdvanced=auto_vacuum=FULL');
	
	result.Open();
end;
I have found some information and so my code is starting to look like the following.

Code: Select all

	
begin
	result := TUniConnection.Create(nil);
	
	result.ProviderName := 'SQLite';
	result.Database := self.DatabaseFullPath;
	result.SpecificOptions.Values['UseUnicode'] := 'True';
	result.SpecificOptions.Values['BusyTimeout'] := '30000';
	
	result.Open();
end;
This works but I want to make sure I have replacements for the other parameters which were being set. I found this forum post (viewtopic.php?t=18840) which provides an example on how to set the journal mode by executing the pragma command. Does this method allow me to set the other parameters?

Another option I thought of was to build the connection string and use that but unfortunately I kept getting errors saying 'Connection parameter name is unknown: XXXX' and couldn't find any documentation to help. I did find this reference to the connection string options in .NET documentation https://www.devart.com/dotconnect/sqlit ... tring.html

Hopefully someone can lead me in the right direction.

ZEuS
Devart Team
Posts: 240
Joined: Thu 05 Apr 2012 07:32

Re: Migrating FireDAC Connection to UniDAC

Post by ZEuS » Thu 23 Aug 2018 11:52

The analogue of the "OpenMode" parameter is the specific option "ForceCreateDatabase" set to "True".
You can set all other parameters using PRAGMA statements in the same way as described at the forum. For detailed information about PRAGMA, please refer to the official SQLite documentation ( sqlite.org/pragma.html ).
The "Connection parameter name is unknown ..." means that the connection parameter you are trying to use is not supported by the connection string. The following parameters are currently supported:
Direct
ClientLibrary
Database
EncryptionAlgorithm
EncryptionKey
ForceCreateDatabase
UseUnicode
UnknownAsString
UserName
CipherLicense

Post Reply