Code to set up a local PostgreSQL database at an HGC MAC
git clone https://github.com/cmu-hgc-mac/HGC_DB_postgres.git
Each MAC requires the following to replicate this setup:
- A database computer with a static IP address or host name with postgreSQL-15 with pgAdmin4 installed.
- Ensure
port
in conn.yaml matches with the port for postgreSQL installed on your computer. Update insitution abbreviation. (Changedb_hostname
only if database is hosted on a different computer.) Verify the CERN database location. - In the long run, it is preferred that the computers at the other stations have static IPs as well for security reasons.
- Decide a postgres superuser password (keep safe), a user password (with write access), and a viewer password (with only read permission; doesn't have to be too complicated.)
- Install postgreSQL-15 with pgAdmin4 on your computers. Make sure you add
psql
to your path. Use the postgres superuser password with pgAdmin4. - Follow instructions to update the two config files to listen for the other computers in the lab and make interconnections.
- In a Python virtual environment or Conda environment:
pip install -r housekeeping/requirements.txt
- Create database and tables with appropriate passwords:
python3 postgres_control_panel.py
Click on the Modify existing tables
button to implement the latest updates to the tables.
- Follow instructions to view tables in pgAdmin4 tool on the database computer. The tables are found under
hgcdb -> Schemas -> public -> Tables
. Right-click on a selected table toview/edit data
for theLast 100 Rows
. - Follow instructions to view tables in pgAdmin4 tool on the other stations.