TElectronMySQLClientDataSet
Designtime |
The component TElectronMySQLClientDataSet
makes it easy for an Electron application to create and use MySQL
databases by a familiar syntax of using ClientDataSet
. It also allows a seamless integration of a MySQL
database with data-aware components like TWebDBGrid
. All the database operations can be done in the standard Delphi way through the TElectronMySQLClientDataSet
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 TElectronMySQLConnection
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 MySQL
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:
CREATE TABLE tasks (
id INT AUTO_INCREMENT PRIMARY KEY,
status VARCHAR(10),
descr TEXT,
due_date DATETIME
);
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 mysql node module: npm install mysql
-
Now you'll need to build the project again before running it.
Set your credentials in the UMySQL_TodoList.pas
unit:
electronMySQLConnection.Host := 'your_host_name';
//this is the default port, replace if yours is different
//electronMySQLConnection.Port := 3306;
electronMySQLConnection.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 UMySQL_Blob.pas
unit:
ElectronMySQLConnection1.Host := 'your_host';
ElectronMySQLConnection1.DatabaseName := 'your_db_name';
//ElectronMySQLConnection1.Port := 3306;
ElectronMySQLConnection1.User := 'your_user';
ElectronMySQLConnection1.Password := 'your_password';
Properties for TElectronMySQLClientDataSet
Property | Description |
---|---|
IndexName | Name of the primary key field of the table |
TableName | Name of the table |