-
Notifications
You must be signed in to change notification settings - Fork 14
CCDB CLI
CCDB provides console tool for introspection and managing constants database. One can run it by 'ccdb' command. Console tools could be used as interactive shell or just like command shell tool.
Example. Single command:
(1) (2) (3)
ccdb -c "mysql://john@localhost:999" ls /TOF/params
-
-c
"mysql://john@localhost" - isccdb
global argument, which sets the connection string. -
ls
- is a ccdb command which returns a list of directories and tables belonging/TOF/params
3/TOF/params
is an argument of thels
command. Like a POSIX shell ls
Example. Interactive session:
ccdb -c "mysql://john@localhost:999" -i (1)
> ls /TOF/params (2)
> help (3)
> cd /TOF (4)
> cd params
> ls
> pwd (5)
> q (6)
-
flag
-i
starts ccdb in interactive mode. -
ls /TOF/params
- the result is exactly the same as in Example 1. One stays in the interactive shell after the execution. -
help
command provides list of commands and how to use each of them -
executing next commands reproduces Example 1 step by step.
-
The same as in POSIX shell, ccdb interactive mode has a current working directory, with relative and absolute paths.
pwd
command shows the current directory. -
to exit interactive mode enter 'q', 'quit' or press ctrl+D
Since ccdb objects have /name/paths and many other things that looks like
POSIX file system, the commands are very posix-shell-like.
ccdb
command uses the connection strings to connect to data source.
-
-c
flag as in the above example -
CCDB_CONNECTION
environment variableexport CCDB_CONNECTION=mysql://ccdb_user@hallddb.jlab.org/ccdb
- In no other connection string is given, CCDB uses
mysql://ccdb_user@localhost/ccdb
-c
flag has the highest priority
ccdb
is designed to be a self descriptive. By using 'help' 'usage' and 'example' commands
one could get all the commands and how to use them.
By using 'howto' command one could get tutorials for typical situations.
Command arguments are choosen to be consistant with other commands. Some flags and argument formats means the same across all commands. What are these flags? There are several types of "objects" in ccdb. Like directories, variation, run nuber. Some commands may be applied for different objects. For example 'info' command may be executed against directory, table or variation There are unified flags to identify objects for all commands:
- -v - Variation
- -t - Data table
- -r - Run or run-range
- -d - Directory
ccdbcmd -i
> info -v default (1)
> info -r all (2)
> info -d /TOF (3)
> info -t /TOF/params (4)
> info /TOF/params (5)
- Get information about "default" variation
- Get information about "all" runrange. "all" runrange is [0, infinite_run]
- Get information about "/TOF" directory.
- Get information about "/TOF/params" type table
- By default 'info' treat non flag argument as a name of a table.
This table is printed if one executes "ccdb help"
(command) | (name) | (description): |
---|---|---|
add | AddData | Add data constants |
info | Info | Prints extended information about an object |
vers | Versions | Show versions of data for the specified table |
run | CurrentRun | gets or sets current working run |
dump | Dump | Dumps datat table to a file |
show | Show | Shows type table data |
mkdir | MakeDirectory | Create directory |
pwd | PrintWorkDir | Prints working directory |
cd | ChangeDir | Change current directory |
mktbl | MakeTable | Create constants type table |
cat | Cat | Show assignment data by ID |
ls | List | List objects in a given directory |
log | Log | Get CCDB changes log |
Assuming that user is in interactive mode, one may categorize the commands:
To navigate directories
-
pwd
- prints curent directory -
cd
- switch to specified directory -
ls
- list objects in the directory (wildcards are allowed) -
mkdir
- creates directory
> pwd
> cd /TOF
> ls
> mkdir constants
> ls con*
Get information about objects
-
info
- gets information about objects (use -v -r -d flags), see example 6. -
vers
- gets all versions of the table -
cat
- displays values -
dump
- same as cat but dumps files to disk -
log
- see logs information
Manage objects
-
mkdir
- creates directory -
mktbl
- creates data table -
add
- adds data from text file to table (variation and runranges are created automatically by add command)