2026-01-23 09:09:53 +03:00
|
|
|
Image = "https://hut.openintegrations.dev/test_data/picture.jpg";
|
2025-03-27 20:05:59 +03:00
|
|
|
OPI_TypeConversion.GetBinaryData(Image); // Image - Type: BinaryData
|
|
|
|
|
|
2025-10-21 11:36:43 +03:00
|
|
|
Address = "127.0.0.1";
|
2025-03-27 20:05:59 +03:00
|
|
|
Login = "bayselonarrend";
|
2025-10-21 11:36:43 +03:00
|
|
|
Password = "12we...";
|
2025-03-27 20:05:59 +03:00
|
|
|
Base = "test_data";
|
|
|
|
|
|
2025-09-01 14:51:24 +03:00
|
|
|
TLS = True;
|
|
|
|
|
Port = 3306;
|
2026-02-10 22:03:20 +03:00
|
|
|
Options = New Structure;
|
|
|
|
|
Options.Insert("addr" , Address);
|
|
|
|
|
Options.Insert("db" , Base);
|
|
|
|
|
Options.Insert("login", Login);
|
|
|
|
|
Options.Insert("pass" , Password);
|
|
|
|
|
Options.Insert("port" , Port);
|
|
|
|
|
|
|
|
|
|
ConnectionString = OPI_TestDataRetrieval.ExecuteTestCLI("mysql", "GenerateConnectionString", Options);
|
2025-09-01 14:51:24 +03:00
|
|
|
|
|
|
|
|
If TLS Then
|
2026-02-10 22:03:20 +03:00
|
|
|
Options = New Structure;
|
|
|
|
|
Options.Insert("trust", True);
|
|
|
|
|
|
|
|
|
|
TLSSettings = OPI_TestDataRetrieval.ExecuteTestCLI("mysql", "GetTLSSettings", Options);
|
2025-09-01 14:51:24 +03:00
|
|
|
Else
|
|
|
|
|
TLSSettings = Undefined;
|
|
|
|
|
EndIf;
|
|
|
|
|
|
|
|
|
|
Connection = OPI_MySQL.CreateConnection(ConnectionString, TLSSettings);
|
2025-03-27 20:05:59 +03:00
|
|
|
|
|
|
|
|
// CREATE
|
|
|
|
|
|
|
|
|
|
QueryText = "
|
|
|
|
|
|CREATE TABLE test_table (
|
|
|
|
|
|id INT AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
|
|name VARCHAR(255),
|
|
|
|
|
|age INT,
|
|
|
|
|
|salary DOUBLE,
|
|
|
|
|
|amount FLOAT,
|
|
|
|
|
|type TINYINT UNSIGNED,
|
|
|
|
|
|date DATE,
|
|
|
|
|
|time TIME,
|
2025-04-02 14:56:42 +03:00
|
|
|
|data MEDIUMBLOB
|
2025-03-27 20:05:59 +03:00
|
|
|
|);";
|
|
|
|
|
|
2026-02-10 22:03:20 +03:00
|
|
|
Options = New Structure;
|
|
|
|
|
Options.Insert("sql", QueryText);
|
|
|
|
|
Options.Insert("dbc", Connection);
|
|
|
|
|
|
|
|
|
|
Result = OPI_TestDataRetrieval.ExecuteTestCLI("mysql", "ExecuteSQLQuery", Options);
|
2025-03-27 20:05:59 +03:00
|
|
|
|
|
|
|
|
// INSERT with parameters
|
|
|
|
|
|
|
|
|
|
QueryText = "
|
|
|
|
|
|INSERT INTO test_table (name, age, salary, amount, type, date, time, data)
|
|
|
|
|
|VALUES (?, ?, ?, ?, ?, ?, ?, ?);";
|
|
|
|
|
|
|
|
|
|
ParameterArray = New Array;
|
|
|
|
|
ParameterArray.Add(New Structure("TEXT" , "Vitaly"));
|
|
|
|
|
ParameterArray.Add(New Structure("INT" , 25));
|
|
|
|
|
ParameterArray.Add(New Structure("DOUBLE", 1000.12));
|
|
|
|
|
ParameterArray.Add(New Structure("FLOAT" , 1000.12));
|
|
|
|
|
ParameterArray.Add(New Structure("UINT" , 1));
|
|
|
|
|
ParameterArray.Add(New Structure("DATE" , OPI_Tools.GetCurrentDate()));
|
|
|
|
|
ParameterArray.Add(New Structure("TIME" , OPI_Tools.GetCurrentDate()));
|
|
|
|
|
ParameterArray.Add(New Structure("BYTES" , Image));
|
|
|
|
|
|
2026-02-10 22:03:20 +03:00
|
|
|
Options = New Structure;
|
|
|
|
|
Options.Insert("sql" , QueryText);
|
|
|
|
|
Options.Insert("params", ParameterArray);
|
|
|
|
|
Options.Insert("dbc" , Connection);
|
|
|
|
|
|
|
|
|
|
Result = OPI_TestDataRetrieval.ExecuteTestCLI("mysql", "ExecuteSQLQuery", Options);
|
2025-03-27 20:05:59 +03:00
|
|
|
|
|
|
|
|
// SELECT (The result of this query is shown in the Result block)
|
|
|
|
|
|
|
|
|
|
QueryText = "SELECT name, age, salary, amount, type, date, time, data FROM test_table;";
|
|
|
|
|
|
2026-02-10 22:03:20 +03:00
|
|
|
Options = New Structure;
|
|
|
|
|
Options.Insert("sql", QueryText);
|
|
|
|
|
Options.Insert("dbc", Connection);
|
|
|
|
|
|
|
|
|
|
Result = OPI_TestDataRetrieval.ExecuteTestCLI("mysql", "ExecuteSQLQuery", Options);
|
2025-03-27 20:05:59 +03:00
|
|
|
|
2025-04-03 21:52:31 +03:00
|
|
|
// SQL query from file
|
|
|
|
|
|
2025-10-21 11:36:43 +03:00
|
|
|
SQLFile = "https://hut.openintegrations.dev/test_data/TEST_DATA2.sql"; // Binary Data, URL or path to file
|
2025-04-03 21:52:31 +03:00
|
|
|
|
2026-02-10 22:03:20 +03:00
|
|
|
Options = New Structure;
|
|
|
|
|
Options.Insert("sql", SQLFile);
|
|
|
|
|
Options.Insert("dbc", Connection);
|
|
|
|
|
|
|
|
|
|
Result = OPI_TestDataRetrieval.ExecuteTestCLI("mysql", "ExecuteSQLQuery", Options);
|
2025-04-03 21:52:31 +03:00
|
|
|
|
2026-01-23 09:09:53 +03:00
|
|
|
Closing = OPI_MySQL.CloseConnection(Connection);
|