db_add_file_to_db#

Summary#

This application adds a file to a DB.

The name and location of the file are required. This application should complement the ones for updating parameters, adding entries to the DB and getting files from the DB.

Command line arguments#

file_name (str or list of str, required)

Name of the file to upload including the full path. A list of files is also allowed, in which case only one -file_name is necessary, i.e., python applications/db_add_file_to_db.py -file_name file_1.dat file_2.dat file_3.dat If no path is given, the file is assumed to be in the CWD.

input_path (str, required if file_name is not given)

A directory with files to upload to the DB. All files in the directory with a predefined list of extensions will be uploaded.

db (str)

The DB to insert the files to. The choices are either the default CTA simulation DB or a sandbox for testing.

verbosity (str, optional)

Log level to print.

Example#

uploading a dummy file.

simtools-db-add-file-to-db --file_name test_application.dat --db test-data

Expected final print-out message:

INFO::get_file_from_db(l75)::main::Got file test_application.dat from DB test-data and
saved into .
db_add_file_to_db.collect_files_to_insert(args_dict, logger, db)[source]#

Collect the files to insert into the database based on the provided arguments.

Parameters:
args_dictdict

Dictionary of parsed command-line arguments.

loggerlogging.Logger

Logger object for logging messages.

dbDatabaseHandler

Database handler object.

Returns:
list

List of files to be inserted into the database.

Raises:
ValueError

If no valid files are provided for uploading.

db_add_file_to_db.confirm_and_insert_files(files_to_insert, args_dict, db, logger)[source]#

Confirm the files to be inserted and insert them into the database.

Parameters:
files_to_insertlist

List of files to be inserted into the database.

args_dictdict

Dictionary of parsed command-line arguments.

dbDatabaseHandler

Database handler object.

loggerlogging.Logger

Logger object for logging messages.