tb sql

Run SQL query over data sources and pipes. Global options apply to this command. See Global options.

Options

OptionDescription
--rows_limit INTEGERMax number of rows retrieved.
--pipeline TEXTThe name of the pipe to run the SQL Query.
--pipe TEXTThe path to the .pipe file to run the SQL Query of a specific NODE.
--node TEXTThe NODE name.
--format [json|csv|human]Output format.
--stats / --no-statsShows query stats.

Examples

The following example shows how to run a SELECT statement with count:

tb sql "SELECT count(*) from tinybird.endpoint_errors" Running against Tinybird Local count() UInt64 ─────────── 0 

The following example shows how to use the --rows_limit and --stats options:

tb sql --rows_limit 5 --stats "SELECT start_datetime, duration, pipe_name from tinybird.pipe_stats_rt" Running against Tinybird Local ** Query took 0.004044331 seconds ** Rows read: 142 ** Bytes read: 10.12 KB start_datetime duration pipe_name DateTime Float32 String ────────────────────────────────────────────────── 2025-03-12 16:07:16 0.05388069 query_api ────────────────────────────────────────────────── 2025-03-12 16:07:27 0.0040593147 query_api ────────────────────────────────────────────────── 2025-03-12 16:09:03 0.026257038 query_api ────────────────────────────────────────────────── 2025-03-12 16:15:27 0.03177452 query_api ────────────────────────────────────────────────── 2025-03-12 16:15:33 0.010550499 query_api 
Updated