Direct SQL Access

Prev Next

If you prefer working from your own tools, you can request direct read-only access to the underlying PostgreSQL database. Please reach out to us at [email protected] to obtain your credentials.

Once you have them, you can connect via:

Third-party SQL Clients

You can connect using your favorite SQL tool. We recommend DBeaver for its user-friendly interface and powerful features.

Typical connection parameters:

  • Driver: PostgreSQL

  • Host: Quantivly server name or IP (e.g., quantivly.yourinstitution.edu)

  • Port: 5432

  • Database: box

  • User: Your provided username

  • Password: Your provided password

💡 Tip: These parameters also let you connect tools like Tableau or PowerBI to build visual dashboards. That’s outside the scope of this tutorial, but fully supported.

Programmatic access (Python)

For advanced data analysis, you can query data directly in Python and integrate with libraries like pandas or scikit-learn.

Install prerequisites:

pip install psycopg2 pandas

Example script:

import psycopg2
import pandas as pd

# Connection details (replace with your credentials)
host = "quantivly.yourinstitution.edu"
port = "5432"
database = "box"
user = "your_username"
password = "your_password"

def connect_to_db():
    """Establish a connection to the PostgreSQL database."""
    try:
        conn = psycopg2.connect(
            host=host, port=port, database=database,
            user=user, password=password
        )
        print("[OK] Connected to database")
        return conn
    except Exception as e:
        print(f"[ERROR] Connection failed: {e}")
        return None

def run_test_query(conn):
    """Run a sample query and display the first 10 rows."""
    query = """
        SELECT examination_datetime, study_descriptions, accession_numbers
        FROM examination
        LIMIT %s;
    """
    try:
        with conn.cursor() as cur:
            cur.execute(query, (10,))
            rows = cur.fetchall()
            df = pd.DataFrame(rows, columns=[desc[0] for desc in cur.description])
            print(df)
    except Exception as e:
        print(f"[ERROR] Query failed: {e}")

def main():
    conn = connect_to_db()
    if conn:
        run_test_query(conn)
        conn.close()
        print("[OK] Connection closed")

if __name__ == "__main__":
    main()

This setup allows you to:

  • Fetch and inspect data in Python

  • Seamlessly move results into pandas

  • Build advanced analytics and machine learning pipelines on top of your Quantivly data

➡️ Quantivly’s built-in metric functions