2025-01-07 12:27:20 +03:00
---
2025-06-09 22:06:01 +03:00
sidebar_position: 6
2025-05-05 11:15:20 +03:00
description: Add rows and other functions to work with SQLite in the Open Integration Package, a free open-source integration library for 1C:Enterprise 8, OneScript and CLI
2025-05-05 09:49:19 +03:00
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, SQLite]
2025-01-07 12:27:20 +03:00
---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
# Add rows
Adds new rows to the table
`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 |
2025-02-11 14:50:59 +03:00
Returns: Map Of KeyAndValue - Result of query execution
2025-01-07 12:27:20 +03:00
<br/>
:::tip
Binary data can also be transferred as a structure `{'blob':File path}`
:::
<br/>
```bsl title="1C:Enterprise/OneScript code example"
2025-06-29 14:35:33 +03:00
Image = "https://hut.openintegrations.dev/test_data/picture.jpg";
2025-01-07 12:27:20 +03:00
OPI_TypeConversion.GetBinaryData(Image); // Image - Type: BinaryData
PictureFile = GetTempFileName("png");
Image.Write(PictureFile); // PictureFile - File to disk
2025-06-29 14:35:33 +03:00
Base = "C:\Users\bayse\AppData\Local\Temp\v8_6B23_336.sqlite";
2025-01-07 12:27:20 +03:00
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" , Image); // BLOB
RowStrucutre1 = New Structure;
2025-03-06 20:58:59 +03:00
RowStrucutre1.Insert("name" , "Lesha"); // TEXT
2025-01-07 12:27:20 +03:00
RowStrucutre1.Insert("age" , 20); // INTEGER
2025-03-06 20:58:59 +03:00
RowStrucutre1.Insert("salary" , 200.20); // REAL
RowStrucutre1.Insert("is_active" , False); // BOOL
2025-01-07 12:27:20 +03:00
RowStrucutre1.Insert("created_at", OPI_Tools.GetCurrentDate()); // DATETIME
RowStrucutre1.Insert("data" , New Structure("blob", PictureFile)); // BLOB
DataArray.Add(RowStructure2);
DataArray.Add(RowStrucutre1);
Result = OPI_SQLite.AddRecords(Table, DataArray, , Base);
```
2025-01-10 12:07:46 +03:00
<Tabs>
<TabItem value="bash" label="Bash" default>
```bash
oint sqlite AddRecords \
--table "test" \
2025-06-18 21:53:54 +03:00
--rows "[{'name':'Vitaly','age':25,'salary':1000.12,'is_active':true,'created_at':'2025-06-18T20:18:27.1754024Z','data':{'blob':'C:\\Users\\Administrator\\AppData\\Local\\Temp\\3frgz1jk3yv.png'}},{'name':'Lesha','age':20,'salary':200.20,'is_active':false,'created_at':'2025-06-18T20:18:27.1754024Z','data':{'blob':'C:\\Users\\Administrator\\AppData\\Local\\Temp\\3frgz1jk3yv.png'}}]" \
--db "C:\Users\Administrator\AppData\Local\Temp\0rltbbruj1o.sqlite"
2025-01-10 12:07:46 +03:00
```
</TabItem>
<TabItem value="bat" label="CMD/Bat" default>
```batch
oint sqlite AddRecords ^
--table "test" ^
2025-06-18 21:53:54 +03:00
--rows "[{'name':'Vitaly','age':25,'salary':1000.12,'is_active':true,'created_at':'2025-06-18T20:18:27.1754024Z','data':{'blob':'C:\\Users\\Administrator\\AppData\\Local\\Temp\\3frgz1jk3yv.png'}},{'name':'Lesha','age':20,'salary':200.20,'is_active':false,'created_at':'2025-06-18T20:18:27.1754024Z','data':{'blob':'C:\\Users\\Administrator\\AppData\\Local\\Temp\\3frgz1jk3yv.png'}}]" ^
--db "C:\Users\Administrator\AppData\Local\Temp\0rltbbruj1o.sqlite"
2025-01-10 12:07:46 +03:00
```
</TabItem>
</Tabs>
```json title="Result"
{
"commit": {
"result": true
},
"result": true,
"rows": 2,
"errors": []
}
```