ALBA CLI

libhdbpp-python CLI

Pre-requisite

  1. PyYAML

  2. psycopg2

  1. Installation Steps

    1. Clone the following repository using this link : https://gitlab.com/tango-controls/hdbpp/libhdbpp-python

    2. Change directory to libhdbpp-python cd libhdbpp-python

    3. Run the below command to begin installation pip install .

      OR

    4. Run make target directly from ska-tango-archiver repo make install-libhdbpp-python

  2. Usage Manual

    1. The hdbpp-reader command-line tool is used for data extraction. Here is the usage manual

    hdbpp-reader [-h] [-v] [-D] [--syslog] [-b BACKEND] [-P] [-c CONFIG] [-C CONNECT] [-d DATABASE] [-H HOST] [-u USER] [-p PASSWORD]
            [-t TIMEFORMAT]
            {list,read} ...
    

    To use timescaledb as the backend, use the –backend argument as follows

    --backend=pyhdbpp.timescaledb.timescaledb.TimescaleDbReader
    
  3. Connection details can be provided using connection string ,config file or argument

    host: <timescaledb_host_name>
    database: <database name>
    user: <database user>
    password :<database password>
    port: <port
    
    1. List Function: to list attributes

    -P --pattern = this option can be used to search pattern
    
    using config file for connection:
    hdbpp-reader --backend=pyhdbpp.timescaledb.timescaledb.TimescaleDbReader -c config.yaml list -P "*"
    
    using connection details as arguments:
    
    hdbpp-reader --backend=pyhdbpp.timescaledb.timescaledb.TimescaleDbReader  list -P "*"
    host (default localhost):10.200.10.143 or timescaledb.ska-eda-mid-db.svc.cluster.local <for mid>
                                        or
    host (default localhost): 10.200.12.14 or timescaledb.ska-eda-low-db.svc.cluster.local <for low>
    port (default 3306):5432
    database (default hdb):ska_archiver_hm_71
    user:admin
    output:
    2022-11-07 17:17:21 hdbpp_reader[685660]: Loaded config file: config.yaml
    tango://tango-host-databaseds-from-makefile-test.ci-ska-tango-archiver-965447b4.svc.cluster.local:10000/sys/tg_test/1/double_scalar
    
    
    Listing attributes double_scalar:
    hdbpp-reader --backend=pyhdbpp.timescaledb.timescaledb.TimescaleDbReader -c config.yaml list -P "*/double_scalar"
    
    Listing attributes of test device:
    hdbpp-reader --backend=pyhdbpp.timescaledb.timescaledb.TimescaleescaleDbReader -c config.yaml list -P "*/sys/tg_test/1/*"
    
    1. READ Function: to list attributes

    -P --pattern = this option can be used to search pattern``
    
    using config file for connection:
    hdbpp-reader --backend=pyhdbpp.timescaledb.timescaledb.TimescaleDbReader -c config.yaml read <attribute_full_name>
    
    for example:
    hdbpp-reader --backend=pyhdbpp.timescaledb.timescaledb.TimescaleDbReader -c config.yaml read tango://tango-host-databaseds-from-makefile-test.ci-ska-tango-archiver-e6c90079.svc.cluster.local:10000/sys/tg_test/1/double_scalar
    output:
    2022-11-07 17:36:00 hdbpp_reader[705016]: Loaded config file: config.yaml
    (datetime.datetime(2022, 11, 7, 11, 29, 1, 489121, tzinfo=datetime.timezone.utc), 87.55708576347412, 0.0, 0, None)
    
    
    using connection details as arguments:
    
    hdbpp-reader --backend=pyhdbpp.timescaledb.timescaledb.TimescaleDbReader  read <attribute_full_name>
    host (default localhost):10.200.10.143 or timescaledb.ska-eda-mid-db.svc.cluster.local <for mid>
                                        or
    host (default localhost): 10.200.12.14 or timescaledb.ska-eda-low-db.svc.cluster.local <for low>
    port (default 3306):5432
    database (default hdb):ska_archiver_hm_71
    user:admin
    password:admin
    
  4. Using Python Console

For using Python Console please refer Timescale DB Reader Jupyter Notebook (timescaledb_reader.ipynb)