Skip to content

Database Update Instruction

ntran18 edited this page Mar 21, 2024 · 3 revisions

The database will be updated by running the scripts, and the front end will be updated, too. The front end displayed the option by querying the database source table, so there was no need to change the code in the front end. Please test in your local database before loading data to the server.

Table of Contents

Update network database locally

  1. Go to database/network-database/scripts folder

  2. Generate new network and preprocessing data by running file generate_new_network_version.py. For more information on how the file works, read the READ.me file in that database/network-database folder. Make sure to have all dependencies installed beforehand or you will recieve errors. (pip3 install intermine, tzlocal, etc. [see file for all imports]

    DB_URL="postgresql://[<db_user>:<password>]@<address to database>/<database name>" python3 generate_new_network_version.py
    

    Ex:

    DB_URL="postgresql://<db_user>:@localhost/postgres" python3 generate_new_network_version.py
    
  3. Load new data to the database by running loader_updates.py

    Usage:

    python3 loader_updates.py | psql postgresql://localhost/postgres
    

Update network database in production database

  1. Connect to the database server via SSH tunnel (with authentication performed by having a known SSH key). You need to ask Dondi for database address and password.

    Usage:

    ssh -L <ssh_tunnel_port>:<database_address>:<db_port> [email protected]
    

    Ex:

    ssh -L 50000:<database_address>:5432 [email protected]
    
  2. Open another terminal window and let the database server window open so it can connect to the database server.

  3. Generate new network and preprocessing data

    Usage:

    DB_URL="postgresql://[<db_user>:<password>]@<address to database>:<ssh tunnel port>/<database name>" python3 generate_new_network_version.py
    

    Ex:

    DB_URL="postgresql://postgres@localhost:50000/postgres" python3 generate_new_network_version.py
    
  4. Load data to the database

    Usage:

    python3 loader_updates.py | psql postgresql://localhost:50000/postgres -U postgres
    
Clone this wiki locally