Skip to main content

Read data from ucn history table

Project description

ucnhistory

Fetch UCN history measurements from SQL database on daq01.ucn.triumf.ca as a pandas DataFrame. Allows for user-friendly timestamp input and write table to csv.

Installation

Clone and install by the following

git clone https://github.com/ucn-triumf/ucnhistory.git
cd ucnhistory
pip install .

which will install the files on the user's python path. One can then import the package from anywhere on the device.

Documentation and Examples

See here for reference

Command line usage:

Help message:

usage: ucnhistory [-h] [-t TABLE] [-s START] [-e END] [-o OUTPUT] [-lt] [-lc] [-c COLUMN]

Fetch tables from ucn history SQL database to csv file

options:
  -h, --help            show this help message and exit
  -t TABLE, --table TABLE
                        Name of table from which to fetch
  -s START, --start START
                        Specify range start date and time
  -e END, --end END     Specify range end date and time
  -o OUTPUT, --output OUTPUT
                        Specify name of output csv file
  -lt, --list_tables    Display tables in database
  -lc, --list_columns   Display columns in database table (must specify table)
  -c COLUMN, --column COLUMN
                        Fetch column from table, use multiple times to get multiple columns. If
                        absent, fetch all columns

Some example usage:

# fetch an table from the past 24h nd save with default filename
ucnhistory -t ucn2epics_measured

# list all available tables
ucnhistory -lt

# list all columns in a table
ucnhistory -lc -t ucn2epics_measured

# get one table for a specified time period
ucnhistory -t ucn2epics_measured -s 'June 6 2024 12pm' -e 'June 6 2024 1pm'

Notes

Database access

Note that access to the database requires the use of a password. This password should be stored in the python keyring in the following way:

import keyring
keyring.set_password("ucn_history", "ucn_reader", password)

The password should be obtained from someone within the group.

SSH access

Access to the DAQ computer is provided by mean of an SSH tunnel. One should copy their public key for password-less access to the machine.

ssh-copy-id ucn@daq01.ucn.triumf.ca

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ucnhistory-0.2.0.tar.gz (30.8 kB view details)

Uploaded Source

File details

Details for the file ucnhistory-0.2.0.tar.gz.

File metadata

  • Download URL: ucnhistory-0.2.0.tar.gz
  • Upload date:
  • Size: 30.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.12

File hashes

Hashes for ucnhistory-0.2.0.tar.gz
Algorithm Hash digest
SHA256 a00d202ac6bf1b507d8083dfaf1b1a7c7447710ad245b5d044054c928f621f24
MD5 b3870a6dd0a1497b28a0b19c0a6aea23
BLAKE2b-256 4d287310a292ddceaaacb64746c5e18f8e0f6aeca9862283feed1653635c0225

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page