PostgreSQL¶
PostgreSQL is a powerful, open-source relational database system with strong standards compliance and extensibility.
Unit: Trysil.Data.FireDAC.PostgreSQL
Delphi Edition: Community
Setup¶
uses
Trysil.Data.FireDAC.PostgreSQL;
TTPostgreSQLConnection.RegisterConnection(
'Main', 'localhost', 'Username', 'Password', 'DatabaseName');
LConnection := TTPostgreSQLConnection.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¶
PostgreSQL uses database sequences for primary key generation:
Map it to the entity:
[TTable('Persons')]
[TSequence('PersonsID')]
type
TPerson = class
strict private
[TPrimaryKey]
[TColumn('ID')]
FID: TTPrimaryKey;
// ...
end;