Skip to main content

Create table

Creates an empty table in the database

Function CreateTable(Val Table, Val ColoumnsStruct, Val Connection = "") Export

ParameterCLI optionTypeRequiredDescription
Table--tableStringTable name
ColoumnsStruct--colsStructure Of KeyAndValueColumn structure: Key > Name, Value > Data type
Connection--dbString, ArbitraryExisting connection or database path
Returns

Map Of KeyAndValue - Result of query execution

1C:Enterprise/OneScript code example
Base = "/tmp/vnnmoosn.qqb.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);
# 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/v3fibjxn.cs0.sqlite"
Result
{
"result": true
}