Skip to content
Dmitry Romanov edited this page Jul 6, 2017 · 15 revisions

CCDB provides 'ccdb' - command line interface for introspection and management of constants. It can be used as interactive shell or to execute single commands.

Example. Single command:

       (1)                           (2)  (3)
ccdb -c "mysql://john@localhost:999" ls /TOF/params
  1. -c "mysql://john@localhost" - is ccdb global argument, which sets the connection string.
  2. ls - is a ccdb command which (like a POSIX ls) prints a list of directories and tables belonging to /TOF/params 3 /TOF/params is an argument of the ls command.

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)
  1. flag -i starts ccdb in the interactive mode.

  2. ls /TOF/params - the result is exactly the same as in the above example.

  3. help command provides list of commands and how to use each of them

  4. ccdb interactive mode has a current working directory, with relative and absolute paths

  5. Same as for POSIX shell, pwd command shows the current directory.

  6. 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.



Connecting to DB

ccdb command uses the connection strings to connect to data source.

  1. -c flag as in the above example
  2. CCDB_CONNECTION environment variable
    export CCDB_CONNECTION=mysql://ccdb_user@hallddb.jlab.org/ccdb
    
  3. In no other connection string is given, CCDB uses
    mysql://ccdb_user@localhost/ccdb
    

-c flag has the highest priority

Help system

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.

Commands

Commands consistancy

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
  • -a - Assignment (usually identified by request or db ID)

Example. Info command:

  ccdbcmd -i
  > info -v default                                          (1)
  > info -r all                                              (2)
  > info -d /TOF                                             (3)
  > info -t /TOF/params                                      (4)
  > info /TOF/params                                         (5)
  1. Get information about "default" variation
  2. Get information about "all" runrange. "all" runrange is [0, infinite_run]
  3. Get information about "/TOF" directory.
  4. Get information about "/TOF/params" type table
  5. By default 'info' treat non flag argument as a name of a table.

Commands overview

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

Example. Directory commands overview:

    > 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)