machcli
The machcli module provides a Machbase client API for JSH applications.
Client
Creates a database client.
Syntax
new Client(config)Configuration fields
host(default:127.0.0.1)port(default:5656)user(default:sys)password(default:manager)alternativeHost(optional)alternativePort(optional)
Usage example
| |
Client.connect()
Opens a connection and returns a Connection object.
Syntax
connect()Client.close()
Closes the underlying database client.
Syntax
close()Client.user()
Returns the configured user name (uppercase).
Syntax
user()Client.normalizeTableName()
Normalizes table name into [database, user, table] format.
Syntax
normalizeTableName(tableName)Connection
Connection object returned by Client.connect().
Connection.query()
Executes a query and returns a Rows object.
Syntax
query(sql[, ...params])Usage example
| |
Connection.queryRow()
Executes a query and returns a single row object.
Returned object includes _ROWNUM and each column as a property.
Syntax
queryRow(sql[, ...params])Connection.exec()
Executes DDL/DML and returns result object.
Returned fields:
rowsAffectedmessage
Syntax
exec(sql[, ...params])Connection.explain()
Returns execution plan text.
Syntax
explain(sql[, ...params])Connection.append()
Creates an appender object for high-volume insert.
The returned appender supports methods such as append(), flush(), close().
Syntax
append(tableName)Usage example
| |
Connection.close()
Closes the connection.
Syntax
close()Rows
Result set object returned by Connection.query().
Rows.message
Message from query execution.
Rows.isFetchable()
Returns whether the result set can fetch rows.
Syntax
isFetchable()Rows.next()
Returns iterator result object:
{ value: Row, done: false }while rows remain{ done: true }when completed
Syntax
next()Rows.close()
Closes the result set.
Syntax
close()Row
Row object generated from a fetched row.
- Each column is available as
row.COLUMN_NAME. for...ofiteration is supported.
queryDatabaseId()
Returns backup tablespace ID for a mounted database.
- Returns
-1for default database (''orMACHBASEDB). - Throws an error when the database is not found.
Syntax
queryDatabaseId(conn, dbName)queryTableType()
Returns table type code by normalized table name tokens.
Syntax
queryTableType(conn, names)TableType and stringTableType()
Table type constants and string converter.
TableType values
Log,Fixed,Volatile,Lookup,KeyValue,Tag
Syntax
stringTableType(type)TableFlag and stringTableFlag()
Table flag constants and string converter.
TableFlag values
None,Data,Rollup,Meta,Stat
Syntax
stringTableFlag(flag)stringTableDescription()
Returns combined table description with type and flag text.
Syntax
stringTableDescription(type, flag)ColumnType and stringColumnType()
Column type constants and string converter.
Main ColumnType values
Short,UShort,Integer,UInteger,Long,ULongFloat,Double,Varchar,Text,Clob,Blob,BinaryDatetime,IPv4,IPv6,JSON
Syntax
stringColumnType(columnType)columnWidth()
Returns default display width for a column type.
Syntax
columnWidth(columnType, length)ColumnFlag and stringColumnFlag()
Column flag constants and string converter.
ColumnFlag values
TagNameBasetimeSummarizedMetaColumn
Syntax
stringColumnFlag(flag)