MariaDB¶
MariaDB is an open-source, MySQL-compatible relational database. Trysil targets MariaDB 10.3 or later, which provides native sequences (CREATE SEQUENCE / NEXTVAL) — required because Trysil assigns the primary key from a sequence before the INSERT.
Unit: Trysil.Data.FireDAC.MariaDB
Delphi Edition: Community (localhost/embedded) · Enterprise/Architect for full client/server
Note
The driver connects through FireDAC's MySQL driver (MariaDB is wire-compatible with the MySQL protocol). The MariaDB client library (libmariadb.dll) must be available at runtime. With the Professional / Community edition FireDAC connects to a localhost server (or embedded) only; connecting to a remote MariaDB server requires the Enterprise or Architect edition.
Setup¶
uses
Trysil.Data.FireDAC.MariaDB;
// Default port (3306)
TTMariaDBConnection.RegisterConnection(
'Main', 'localhost', 'user', 'password', 'mydb');
// Explicit port
TTMariaDBConnection.RegisterConnection(
'Main', 'localhost', 3306, 'user', 'password', 'mydb');
LConnection := TTMariaDBConnection.Create('Main');
try
LContext := TTContext.Create(LConnection);
try
// Use the context...
finally
LContext.Free;
end;
finally
LConnection.Free;
end;
Connection Pooling¶
Enable connection pooling for server applications:
Sequences¶
MariaDB 10.3+ supports native sequences:
The sequence value is retrieved using NEXTVAL:
Map it to the entity:
[TTable('Persons')]
[TSequence('PersonsID')]
type
TPerson = class
strict private
[TPrimaryKey]
[TColumn('ID')]
FID: TTPrimaryKey;
// ...
end;