﻿---
sidebar_position: 7
description: Get records 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';

# Get records
 Gets records from the selected table



`Function GetRecords(Val Table, Val Fields = "*", Val Filters = "", Val Sort = "", Val Count = "", Val Connection = "") Export`

  | Parameter | CLI option | Type | Required | Description |
  |-|-|-|-|-|
  | Table | --table | String | &#x2714; | Table name |
  | Fields | --fields | Array Of String | &#x2716; | Fields for selection |
  | Filters | --filter | Array of Structure | &#x2716; | Filters array. See GetRecordsFilterStrucutre |
  | Sort | --order | Structure Of KeyAndValue | &#x2716; | Sorting: Key > field name, Value > direction (ASC, DESC) |
  | Count | --limit | Number | &#x2716; | Limiting the number of received strings |
  | Connection | --db | String, Arbitrary | &#x2716; | Existing connection or database path |

  
  Returns:  Map Of KeyAndValue - Result of query execution

<br/>

:::tip
Values of the Binary data type (BLOB) are returned as `{'blob':Base64 string}`
:::
<br/>


```bsl title="1C:Enterprise/OneScript code example"
    Base  = "C:\Users\bayse\AppData\Local\Temp\v8_9AEF_2c.sqlite";
    Table = "test";

    Fields = New Array;
    Fields.Add("name");
    Fields.Add("salary");

    Filters = New Array;

    FilterStructure1 = New Structure;

    FilterStructure1.Insert("field", "name");
    FilterStructure1.Insert("type" , "=");
    FilterStructure1.Insert("value", "Vitaly");
    FilterStructure1.Insert("union", "AND");
    FilterStructure1.Insert("raw"  , False);

    FilterStructure2 = New Structure;

    FilterStructure2.Insert("field", "age");
    FilterStructure2.Insert("type" , "BETWEEN");
    FilterStructure2.Insert("value", "20 AND 30");
    FilterStructure2.Insert("raw"  , True);

    Filters.Add(FilterStructure1);
    Filters.Add(FilterStructure2);

    Sort  = New Structure("created_at", "DESC");
    Count = 1;

    Result = OPI_SQLite.GetRecords(Table, Fields, Filters, Sort, Count, Base);
```
 

 <Tabs>
  
    <TabItem value="bash" label="Bash" default>
        ```bash
            oint sqlite GetRecords \
             --table "test" \
             --db "/tmp/1q3umrdj.x1r.sqlite"
        ```
    </TabItem>
  
    <TabItem value="bat" label="CMD/Bat" default>
        ```batch
            oint sqlite GetRecords ^
             --table "test" ^
             --db "/tmp/1q3umrdj.x1r.sqlite"
        ```
    </TabItem>
</Tabs>


```json title="Result"
{
 "data": [
  {
   "name": "Vitaly",
   "salary": 1000.12
  }
 ],
 "result": true
}
```
