main 9.0
No Matches
'abrain' - a server who provide a simple 'sqlLite' based database server


abrain is a LibMsgque server and a wrapper for the sqlLite library to provide a database.
abrain server is best explained with a picture:

and the workflow:

abrain is a small database server for sqlLite.

The server is addressed via pipe, unix-domain-socket or network-socket and finally forwards the SQL to sqlLite.

The supported data-types are the data-types supported in LibMkKernel and are mapped to sqlLite. In order to enforce the data-types supported by LibMkKernel, these are checked in the passed SQL argument as well as in the results.

public database services

OPEN open-name

Open the database using open-name as:

open-nameone of file-name, :memory: or ""
nothing, the context is linked to the database-id
type open-name
file based file-name
memory :memory:
tempdb ""


Close database, reset DATA

nothing, but instance can be reused again

EXEC sql-string

Execute sql-string.

sql-stringSQL string using sqlLite syntax
nothing, no results are expected

PREP ?prepare-id? sql-string → prepare-id

Prepare sql-string

prepare-id(optional) - use this id
sql-string(required) - SQL string using sqlLite syntax
prepare-id - initial one or next free one
A simple SQL insert
  • /* in:IDC */ INSERT INTO testtbl (id, dval, cval) VALUES (?, ?, ?);
The in:IDC is an addition to SQL to enforce the datatype.
  • Supported are in:xxx and out:xxx
The xxx argument is one or more ONE character type-identifer from PRIMITIVE TYPE.
  • in:IDC = input argument type: I Integer, D Double and C String

FINA prepare-id

Finalize prepare-id

prepare-idresult from PREP

STEP prepare-id args... → results

Call prepare-id with argument and propably expect result

prepare-idresult from PREP
args...multiple arguments
list of results

The STEP is using the definition from in:xxx and out:xxx to extract the required results from the prepare-id

Create a simple workflow to fill and select a table:
# create working context
set FH [tclmsgque::MqMsgque::MqContextC Create]
# link to the database server
$FH LinkCreate --host rmthost --port rmtPort
# open remote database - using file "myDatabase.db"
$FH Send "W" "OPEN:C" "myDatabase.db"
# 1. create table
$FH Send "W" "EXEC:C" "CREATE TABLE testtbl (id INTEGER PRIMARY KEY, dval double, cval TEXT NOT NULL);"
# 2. prepare statement for insert using "prepare-id" == 0
$FH Send "W" "PREP:IC@I" 0 "/* in:IDC */ INSERT INTO testtbl (id, dval, cval) VALUES (?, ?, ?);"
# 3. insert data
$FH Send "W" "STEP:IIDC" 0 1 0.3 otto
$FH Send "W" "STEP:IIDC" 0 2 0.4 otto2
$FH Send "W" "STEP:IIDC" 0 3 0.5 otto3
# 4. prepare select statement using "prepare-id" == 1
$FH Send "W" "PREP:IC@I" 1 "/* in:I out:DC */ SELECT dval, cval FROM testtbl WHERE id < ?;"
# 5. select data
$FH Send "W" "STEP:II@L" 1 2
# delete connection
$FH Delete

Source-Code of "abrain"


usage: abrain [OPTION]... [ARGUMENT]...

  This tool is the database server of NHI1.

  abrain [ARGUMENT]... syntax:
    aclient [OPTION]... @ abrain [OPTION]... [ARGUMENT]

  msgque [OPTION]:
    --help-msgque    print msgque specific help

  abrain [OPTION]:
    -h, --help       print this help