The SCDBClient is a terminal client that allows users to work with the SCDB server. The client provides several commands and options for interacting with the server.
build scdbclient from source
go build -o scdbclient cmd/scdbclient/main.go
# try scdbclient
./scdbclient --help
The following commands are available in the SCDBClient:
- help: Provides help about any command.
- prompt: Enables interactive query mode, allowing the user to issue queries to the SCDB server.
- source: Executes SCQL statements in a script file.
The following flags are available in the SCDBClient for customizing its behavior
--host: SCDB server host (default "http://localhost:8080").
--userName: User name for SCDB user.
--passwd: User password for SCDB user.
--usersConfFileName: User conf file name (default "cmd/scdbclient/users.json")
--sourceFile: scql statement script file
--sync: Determines whether queries are executed in synchronous or asynchronous mode (default asynchronous).
--pollingTimes: Polling times. If pollingTimes <=0, polling until the result is obtained.
--pollingTimeIntervalSeconds: Polling times interval in seconds (default 1s).
To use the SCDBClient, simply run the client with a command and some relevant flags.
To submit a query to SCDB, the client needs to provide necessary user information, we can use usersConfFileName parameter to refer to a file, such as user.json, which contains pre-filled user information that correspond to the user information stored in the SCQL system.
$ ./scdbclient prompt --host=http://example.com --usersConfFileName=/path/to/user.json
> switch alice
alice> select ...
In addition to read user information from json file, The client also supports filling in user information via the command line.
# please fill your user name, password in this command
$ ./scdbclient prompt --host=http://example.com --userName= --passwd=
alice> select ...
Except work in interactive mode, it is also possible for client to read quires from a sql file that contains the statements you wish to execute. To do this you need to use source
and sourceFile
as follows:
./scdbclient source --host=http://example.com --usersConfFileName=users.json --sourceFile=/path/to/script.sql
The SCDB server provides two APIs, namely Submit and SubmitAndGet, to allow clients to submit queries. Clients can specify their preferred option by using the sync
flag
# Submit (default)
./scdbclient prompt --host=http://example.com --usersConfFileName=users.json
# SubmitAndGet
./scdbclient prompt --host=http://example.com --usersConfFileName=users.json --sync
Type exit
or quit
to exit