TElectronPostgreSQLClientDataSet
![]() |
---|
Designtime |
The component TElectronPostgreSQLClientDataSet
makes it easy for an Electron application to create and use PostgreSQL
databases by a familiar syntax of using ClientDataSet
. It also allows a seamless integration of a PostgreSQL
database with data-aware components like TWebDBGrid
. All the database operations can be done in the standard Delphi way through the TElectronPostgreSQLClientDataSet
component.
Please follow the steps explained in the "Set up your project with local databases" section of this documentation. After the initial setup, all you need to do is specify the TableName
and IndexName
properties and add the field definitions either in design time or in code in a standard Delphi syntax. Then connect it to a TElectronPostgreSQLConnection
component, connect a DataSource
and Data
components to it and make the dataset active.
Todo List Demo
You can set up a database for the demo either locally by downloading and installing PostgreSQL
or by using an online service. In case of an online service it's better to save your credentials somewhere safe as you might not be able to retrieve them later. After the database has been created you can use the following SQL
command to create a table that matches the expected syntax of our Todo List Demo:
Before you run the demo, first you need to install the correct node module in the output folder of the project:
- Build the project and go to the output folder based on your configuration (Debug, Build-...).
-
Install the pg node module:
npm install pg
-
Now you'll need to build the project again before running it. Set your credentials in the
UPostgreSQL_TodoList.pas
unit:
pgConnection.Host := 'your_host_name';
//this is the default port, replace if yours is different
//pgConnection.Port := 5432;
pgConnection.DatabaseName := 'your_db_name';
BLOB demo
For detailed setup, refer to the Todo List Demo description.
SQL
command to create the table:
Set your credentials in the UPostgreSQL_Blob.pas
unit:
ElectronPostgreSQLConnection1.Host := 'your_host';
ElectronPostgreSQLConnection1.DatabaseName := 'your_db_name';
//ElectronPostgreSQLConnection1.Port := 5432;
ElectronPostgreSQLConnection1.User := 'your_user';
ElectronPostgreSQLConnection1.Password := 'your_password';
Properties for TElectronPostgreSQLClientDataSet
Property | Description |
---|---|
IndexName | Name of the primary key field of the table |
TableName | Name of the table |