--- title: "Direct SQL Access" slug: "direct-sql-access" updated: 2026-09-23T22:32:57Z published: 2026-09-23T22:32:57Z canonical: "docs.quantivly.com/direct-sql-access" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.quantivly.com/llms.txt > Use this file to discover all available pages before exploring further. # Direct SQL Access If you prefer working from your own tools, you can ask about direct read-only access to the underlying **PostgreSQL database**. Contact your Quantivly team at [contact-cx@quantivly.com](mailto:contact-cx@quantivly.com) to check whether it can be set up for your site and to get your connection details. Once access is set up, you can connect via: - [Third-party SQL clients](/v1/docs/direct-sql-access#thirdparty-sql-clients) - [Programmatic access (Python or other languages)](/v1/docs/direct-sql-access#programmatic-access-python) > ⚠️ **Patient data:** read-only access includes patient identifiers such as medical record numbers, names and birth dates. Handle any data you export (for example into Tableau, Power BI or pandas) according to your organization's policies for protected health information (PHI). ### **Third-party SQL Clients** You can connect using your favorite SQL tool. We recommend [DBeaver](https://dbeaver.io/) 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` (default) - **Database:** `box` (default) - **User:** *Your provided username* - **Password:** *Your provided password* Port and database name can differ from site to site, and the database may only be reachable from your internal network or VPN. Your Quantivly team will confirm the exact host, port and database for your site, and whether an encrypted (SSL) connection is required. > 💡 **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:** ```python pip install psycopg2 pandas ``` **Example script:** ```python 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](/v1/docs/quantivlys-built-in-metric-functions)