Add rows
Adds new rows to the table
- Parameters
- Advanced call ?
Function AddRecords(Val Table, Val DataArray, Val Transaction = True, Val Connection = "") Export
| Parameter | CLI option | Type | Required | Description |
|---|---|---|---|---|
| Table | --table | String | ✔ | Table name |
| DataArray | --rows | Array of Structure | ✔ | An array of string data structures: Key > field, Value > field value |
| Transaction | --trn | Boolean | ✖ | True > adding records to transactions with rollback on error |
| Connection | --db | String, Arbitrary | ✖ | Existing connection or database path |
Returns
Map Of KeyAndValue - Result of query execution
| Parameter | Description |
|---|---|
| addin_mode | Manual selection of external component connection mode (for 1C): Isolated, NotIsolated |
| dontwait | Creates a background job and returns its data (for 1C and OneScript only) |
tip
Binary data can also be transferred as a structure {'blob':File path}
1C:Enterprise/OneScript code example
Image = "https://hut.openintegrations.dev/test_data/picture.jpg";
OPI_TypeConversion.GetBinaryData(Image); // Image - Type: BinaryData
PictureFile = GetTempFileName("png");
Image.Write(PictureFile); // PictureFile - File to disk
Base = "/tmp/vnnmoosn.qqb.sqlite";
Table = "test";
DataArray = New Array;
RowStructure2 = New Structure;
RowStructure2.Insert("name" , "Vitaly"); // TEXT
RowStructure2.Insert("age" , 25); // INTEGER
RowStructure2.Insert("salary" , 1000.12); // REAL
RowStructure2.Insert("is_active" , True); // BOOL
RowStructure2.Insert("created_at", OPI_Tools.GetCurrentDate()); // DATETIME
RowStructure2.Insert("data" , New Structure("blob", Image)); // BLOB
RowStructure1 = New Structure;
RowStructure1.Insert("name" , "Lesha"); // TEXT
RowStructure1.Insert("age" , 20); // INTEGER
RowStructure1.Insert("salary" , 200.20); // REAL
RowStructure1.Insert("is_active" , False); // BOOL
RowStructure1.Insert("created_at", OPI_Tools.GetCurrentDate()); // DATETIME
RowStructure1.Insert("data" , New Structure("blob", PictureFile)); // BLOB
DataArray.Add(RowStructure2);
DataArray.Add(RowStructure1);
Result = OPI_SQLite.AddRecords(Table, DataArray, , Base);
- Bash
- CMD/Bat
# JSON data can also be passed as a path to a .json file
oint sqlite AddRecords \
--table "test1" \
--rows "{'[An obscure column]':'yo'}" \
--db "/tmp/v3fibjxn.cs0.sqlite"
:: JSON data can also be passed as a path to a .json file
oint sqlite AddRecords ^
--table "test1" ^
--rows "{'[An obscure column]':'yo'}" ^
--db "/tmp/v3fibjxn.cs0.sqlite"
Result
{
"commit": {
"result": true
},
"result": true,
"rows": 2,
"errors": []
}