SQL CLIENTS & USAGE

📘

IMPORTANT NOTE:

This website (docs.data.nasdaq.com) will be retired on August 31 2026. Please bookmark our new Data Access Tools page for continued access to documentation and resources.

CLI

  1. Download latest cli from trino.io
  2. Save .trino_config to your $HOME folder
  3. Update .trino_config with your configurations
    1. set user as your API Key
    2. optional - replace the server value for a custom HOST
  4. Run queries as desired
$ trino --execute 'select * from ndaq_rtat10 limit 5'
$ trino --execute 'select * from zacks_hdm limit 5'

Python

Here is a sample Python Code to write directly to disk. You'll need to adjust the user to your Data Link API Key.

"""
DataLink Trino Connection - Getting Started Example

This file demonstrates how to get started with DataLink's Trino native JDBC connection.
Use this as a reference to implement a solution based on your specific needs.

DataLink supports Trino native JDBC connections, so customers can use their own implementation
using the Trino JDBC driver: https://trino.io/docs/current/client/jdbc.html

Important:
- Review all TODO comments in this file to customize the query and processing logic for your use case.

Troubleshooting:
- If you are having issues with any query, please enable debug logging (set logging level to DEBUG).
- Debug mode will provide you with the query ID.
- Please provide the query ID to the DataLink Client Success team for assistance.
"""

import logging
from trino.dbapi import connect

def _extract_query_id(cur):
    q = getattr(cur, "query_id", None) or getattr(cur, "_query_id", None)
    try:
        if not q and hasattr(cur, "_operation") and isinstance(cur._operation, dict):
            q = cur._operation.get("queryId") or cur._operation.get("query_id")
    except Exception:
        pass
    return q

conn = connect(
    host="data.nasdaq.com",
    port=443,
    user="TODO: your api_key here",
    catalog="main",
    schema="huron",
    http_scheme="https"
)

# Configure logging
logging.basicConfig(
    level=logging.DEBUG,
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)

#TODO: replace with your query
sql = ("SELECT 1 LIMIT 10")

try:
    cur = conn.cursor()
    cur.execute(sql)
    # Immediately try to read and print the query id after execute succeeds
    if(logger.isEnabledFor(logging.DEBUG)):
        query_id = _extract_query_id(cur)
        logger.debug(f"--------- Trino query id -------: {query_id}")
    
    # use fetchall()/fetchone()/fetchmany() as needed https://github.com/trinodb/trino-python-client#db-api
    rows = cur.fetchmany(size=1000)
    for row in rows:
        logger.info(f"Row: {row}")
    # TODO: process rows as needed!

except Exception as exc:
    # If execute raised, try to extract/print query id anyway, then re-raise
    query_id = _extract_query_id(cur)
    logger.error(f"Trino query id (after error): {query_id}")
    raise
finally:
    # Safety: if for any reason we haven't printed the id yet, attempt once more
    cur.close()
    logger.info("Closing Trino connection")
📘

NOTE:

Tested with Python 3

DotNet C#

  1. Add DataLinkSQL.csproj in a new project folder, or install those Nuget packages into your existing project.
  2. Configure environment variables
    1. NASDAQ_DATA_LINK_API_KEY for your API Key
    2. Optional - NASDAQ_DATA_LINK_BASE_DOMAIN for a custom HOST
  3. Add DataLinkSQL.cs to your project folder
  4. Run included Main to invoke sample queries
$ dotnet run --property DefineConstants=INCLUDE_MAIN
  1. Additionally, create a new module with your desired queries and reuse helper functions
using NReco.PrestoAdo;
using static DataLinkSQL;

class MyApp
{
    static void Main()
    {
        using (PrestoConnection connection = CreateConnection())
        {
            string sql = "...";
            DbDataReader reader = RunSQL(connection, sql);
            DisplayReader(reader);
        }
    }
}
$ dotnet run
📘

NOTE:

Tested with Python 3

Tableau

  1. Connect "To a Server" and select "Presto"
  2. Enter configurations as explained in Endpoints, and also set
    1. Authentication: Username
    2. Require SSL: True
  3. Click the magnifying glass next to the "Enter table name" text box
  4. You should now see all your tables. Drag and drop them to build your models.
📘

NOTE:

Tested with Tableau Desktop 2022.2

DataGrip

Install JDBC driver

  1. Download the latest driver from trino.io
  2. Move the driver into a permanent location (where it won't get deleted accidentally); i.e., the DataGrip library folder
    1. in MacOS, this is ~/Library/Application\ Support/JetBrains/DataGrip${VERSION}/jdbc-drivers/
  3. Open DataGrip
  4. Click: File > New > Driver
  5. Fill in fields
    1. Name: Trino 406
    2. General (tab)
      1. Driver files: browse and select the downloaded driver
      2. Class: io.trino.jdbc.TrinoDriver
    3. Options (tab)
      1. Other (section)
        1. Icon: Trino
  6. Click Apply and OK

Set-up Data Source

  1. Open DataGrip
  2. Click: File > New > DataSource > Trino 406
  3. Fill in fields as explained in Endpoints
    1. Name: DataLink
    2. General (tab)
      1. User: your API Key
      2. URL: jdbc:trino://${HOST}:${PORT}/${CATALOG}/${SCHEMA}
  4. Click Apply and OK