# Accessing the ToMCAT Dataset

## Overview

This guide provides instructions on how to access the ToMCAT database using either the public API or by directly connecting to the PostgreSQL instance hosted on the **Gauss** server via `pgAdmin`.

## Access Options

### Option 1: Accessing via Public API

You can access the public (SQLite3) version of the ToMCAT database programmatically using Datasette, through the following API endpoints:

- [Datasette Pages Documentation](https://docs.datasette.io/en/stable/pages.html)
- [Datasette JSON API](https://docs.datasette.io/en/stable/json_api.html)

### Option 2: Working with a Local SQLite3 Database

You also have the option to download the SQLite3 database locally and work with it directly. 

### Option 3: Working with Postgres database on Gauss

Additionally, you can programmatically interact with the PostgreSQL database instance running on Gauss by following the steps outlined below.

---

1. **Clone the ToMCAT Repository**
To begin, clone the ToMCAT repository and navigate to the `/tools` directory in the `master` branch:
    
    ```bash
    git clone <https://github.com/ml4ai/tomcat.git>
    cd tomcat/tools
    ```
    
2. **Set Up Port Forwarding**
To establish a connection between your local machine and the PostgreSQL database hosted on Gauss, use the port forwarding script:
    
    ```bash
    ./port_forwarder start gauss 5433
    ```
    
3. **Download and Install `pgAdmin`**
Download and install `pgAdmin` by visiting the [pgAdmin website](https://www.pgadmin.org/download/). Be sure to download the appropriate version for your operating system.
4. **Register a New Database in `pgAdmin`**
After installing `pgAdmin`, follow these steps to register a new database connection:
    - Open `pgAdmin`.
    - Right-click on **Server** in the left panel, click **Register**, and then select **Server**.
    - In the registration form, enter the following details:
        - **Host name/address**: `localhost`
        - **Port**: `5433` (the port forwarded from Gauss)
        - **Maintenance Database**: `postgres`
        - **Username**: Your (Gauss) username
        - **Password (optional)**:
    - Click on Save Password.
    - Once the details are entered, click **Save**.
5. **Verify the Connection**
After saving, you should now see the databases in the Gauss cluster, including the one entered as the maintenance database. You can now query tables and view their properties using the user-friendly interface provided by `pgAdmin`.

---