reload.bat - Samuel-Buteau/universal-battery-database GitHub Wiki
Using this script...
To run reload.bat
, enter the following into Command Prompt.
>reload.bat your_database_name your_user_name "your_dataset_path"
The command line argument %1
is the name for the database; %2
is the name of the owner (user from PostgreSQL); %3
is the folder that contains the data files.
When prompted by Postgres, as shown below, enter the password for the default user (the user used to create other users) for the database. This is not the same as the password in cycling/config.ini
.
Password for user postgres:
What this script does...
In summary, this script:
- Removes any previous database that might exist with the specified name and creates a brand new empty one, linked to the specified user. This is done using the "default" user (typically, the user called
postgres
, with the password you set when installing the postgresql application). This step does not care about what is inconfig.ini
. - Runs the application. Whenever the application tries to modify the contents of the database (for instance adding data from your raw data files), it needs some access to the database, and this access is specified in
config.ini
.
Destroying an existing database:
Dropping database %1;
Creating a database:
echo create database %1 with owner %2;
Creating tables in the database:
python manage.py makemigrations
python manage.py migrate
Populating tables in the database with various information defining the file names (e.g. what they mean, how they map to metadata, etc.):
python manage.py edit_database_filename_database --mode add_category
python manage.py edit_database_filename_database --mode add_charger_drive_profile
python manage.py edit_database_filename_database --mode add_experiment_type
python manage.py edit_database_filename_database --mode display --model Category
python manage.py edit_database_filename_database --mode display --model ChargerDriveProfile
python manage.py edit_database_filename_database --mode display --model ExperimentType
Adding files from the given data folder:
python manage.py edit_database_filename_database --mode just_add_files --data_dir=%3
The above command above can be run as many times as necessary. For example, you could schedule this command to be run everyday at midnight. The program will go into the specified folder and check for changes, such as new, deleted, and modified files, and update the tables in the database in the program's memory (a virtual file system).
Processing the file names in the virtual file system:
python manage.py edit_database_filename_database --mode just_parse_database_files
For file formats that follow a lab's chosen convention, the process will succeed and valid metadata will be extracted. For other problematic files, the process stops, and though some metadata will still be extracted, not all will be valid.