1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2025-11-25 22:12:29 +02:00
Files
OpenIntegrations/docs/en/md/SQLite/Orm/Create-table.mdx
Vitaly the Alpaca (bot) 9da5607c44 Main build (Jenkins)
2025-10-18 15:42:04 +03:00

78 lines
2.3 KiB
Plaintext
Vendored

---
sidebar_position: 2
description: Create table 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';
# Create table
Creates an empty table in the database
`Function CreateTable(Val Table, Val ColoumnsStruct, Val Connection = "") Export`
| Parameter | CLI option | Type | Required | Description |
|-|-|-|-|-|
| Table | --table | String | ✔ | Table name |
| ColoumnsStruct | --cols | Structure Of KeyAndValue | ✔ | Column structure: Key > Name, Value > Data type |
| Connection | --db | String, Arbitrary | ✖ | Existing connection or database path |
Returns: Map Of KeyAndValue - Result of query execution
<br/>
```bsl title="1C:Enterprise/OneScript code example"
Base = "C:\Users\bayse\AppData\Local\Temp\v8_FF37_66.sqlite";
Table = "test";
ColoumnsStruct = New Structure;
ColoumnsStruct.Insert("id" , "INTEGER PRIMARY KEY");
ColoumnsStruct.Insert("name" , "TEXT");
ColoumnsStruct.Insert("age" , "INTEGER");
ColoumnsStruct.Insert("salary" , "REAL");
ColoumnsStruct.Insert("is_active" , "BOOLEAN");
ColoumnsStruct.Insert("created_at", "DATETIME");
ColoumnsStruct.Insert("data" , "BLOB");
Result = OPI_SQLite.CreateTable(Table, ColoumnsStruct, Base);
```
<Tabs>
<TabItem value="bash" label="Bash" default>
```bash
# JSON data can also be passed as a path to a .json file
oint sqlite CreateTable \
--table "test1" \
--cols "{'id':'INTEGER PRIMARY KEY','[An obscure column]':'TEXT'}" \
--db "/tmp/1q3umrdj.x1r.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 CreateTable ^
--table "test1" ^
--cols "{'id':'INTEGER PRIMARY KEY','[An obscure column]':'TEXT'}" ^
--db "/tmp/1q3umrdj.x1r.sqlite"
```
</TabItem>
</Tabs>
```json title="Result"
{
"result": true
}
```