Covers how to configure a TMMConnection instance and
verify connectivity before running scripts or writing data.
TMMConnection is a TComponent; create it
with an owner or nil, then set its properties:
uses EDBMMClient;
var Conn: TMMConnection;
Conn := TMMConnection.Create(nil);
Conn.Database := EDBDatabase1; // EDB database (must remain open)
Conn.APIURL := 'https://myserver.com/edbapi.php';
Conn.APIKey := 'my-secret-key'; // value sent as X-API-Key; '' = no auth
Conn.DBHost := ''; // MySQL host; '' = use server config.php
Conn.DBName := 'my_db';
Conn.DBUser := 'myuser';
Conn.DBPassword := 'mypassword';
Conn.TimeoutMs := 0; // 0 = built-in defaults
Conn.OnLog := HandleLog; // TMMLogEvent -- see 04010701
Any credential left empty causes the server to fall back to the value
defined in config.php.
Storing credentials in config.php (outside the webroot)
means the client application does not need to hold the database
password.
OnLog is of type TMMLogEvent.
Declare a named procedure in your form or data module and assign it
directly:
procedure TMyForm.HandleLog(Sender: TObject; const Msg: string);
begin
Memo1.Lines.Add(Msg);
end;
Conn.OnLog := HandleLog;
Properties can be changed at any time between calls; there is no persistent connection to close.
Assign the same TMMConnection instance to multiple
TMMScript or TMMUpdater objects. Each owns its
own HTTP client, so they are independent:
Script1.Connection := Conn;
Script2.Connection := Conn;
Updater1.Connection := Conn;
TMMConnection is not thread-safe. Use
one instance per thread.
var Msg, Version: string;
// Ping: checks API reachability only — no database connection attempted
if not Conn.Ping(Msg) then
ShowMessage('API not reachable: ' + Msg);
// TestConnection: opens a MySQL/MariaDB connection and returns the server version
if not Conn.TestConnection(Version, Msg) then
ShowMessage('DB connection failed: ' + Msg)
else
ShowMessage('Connected: ' + Version);
| Operation | Timeout | Controlled by TimeoutMs |
|---|---|---|
Ping |
10 s | Yes |
TestConnection |
30 s | Yes |
ColumnInfo |
30 s | No |
TableColumnsInfo |
30 s | No |
TableExists, ViewExists,
ColumnExists and other Exists methods |
30 s | No |
| Each upload chunk | 60 s | No |
| Script execution | 5 min | No |
| Each result page download | 30 min | No |
TMMScript.FetchBlob / FetchBlobBytes |
30 min | No |
TMMUpdater.Execute batch (BLOB/CLOB tables) |
30 min | No |
TMMUpdater.Execute batch (text-only tables) |
2 min | No |
TMMUpdater.Execute BLOB chunk upload |
5 min | No |
TimeoutMs overrides only Ping and
TestConnection when set to a non-zero value. All other
timeouts are fixed.