﻿---
sidebar_position: 6
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
keywords: [1C, 1С, 1С:Enterprise, 1С:Enterprise 8.3, API, Integration, Services, Exchange, OneScript, CLI, SQLite]
---

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 | &#x2714; | Table name |
  | DataArray | --rows | Array of Structure | &#x2714; | An array of string data structures: Key > field, Value > field value |
  | Transaction | --trn | Boolean | &#x2716; | True > adding records to transactions with rollback on error |
  | Connection | --db | String, Arbitrary | &#x2716; | Existing connection or database path |

  
  Returns:  Map Of KeyAndValue - Result of query execution

<br/>

:::tip
Binary data can also be transferred as a structure `{'blob':File path}`
:::
<br/>


```bsl title="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  = "C:\Users\bayse\AppData\Local\Temp\v8_CED4_274.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

    RowStrucutre1 = New Structure;
    RowStrucutre1.Insert("name"      , "Lesha"); // TEXT
    RowStrucutre1.Insert("age"       , 20); // INTEGER
    RowStrucutre1.Insert("salary"    , 200.20); // REAL
    RowStrucutre1.Insert("is_active" , False); // BOOL
    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);
```
 

 <Tabs>
  
    <TabItem value="bash" label="Bash" default>
        ```bash
            # 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/irt1oajf.wt5.sqlite"
        ```
    </TabItem>
  
    <TabItem value="bat" label="CMD/Bat" default>
        ```batch
            :: 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/irt1oajf.wt5.sqlite"
        ```
    </TabItem>
</Tabs>


```json title="Result"
{
 "commit": {
  "result": true
 },
 "result": true,
 "rows": 2,
 "errors": []
}
```
