TTQL (TableTalk Query Language)
TTQL (TableTalk Query Language) is a federated, cross-database query engine and AST parser written in pure Dart. It enables executing read-only analytical queries that join data across heterogeneous database systems (PostgreSQL, MySQL, SQLite, MongoDB, Redis) in a single script.
const pg = environment.connections.ecommerce_pg;
const mysql = environment.connections.inventory_mysql;
const mongo = environment.connections.analytics_mongo;
from(pg.customers as c)
.innerJoin(mysql.shipments as s, on: c.customer_id == s.customer_id)
.leftJoin(mongo.events as e, on: c.customer_id == e.customer_id)
.where(c.country == 'US' && s.status == 'in_transit')
.select([c.customer_id, c.email, s.carrier, e.event_type])
.limit(25);
Official Visual Client & Local-AI Workspace — TableTalk Studio
ttqlis 100% open source (CLI, LSP server, VS Code extension, and Dart compiler library). When you want a turnkey desktop/mobile GUI built around TTQL — featuring OS Keychain credential vaulting, 1-click Server Pool discovery, visual cross-DB ERD graphs, and local Ollama AI query generation &EXPLAIN ANALYZEprofiling — check out TableTalk Studio.
Key Features
- Federated Cross-Engine Joins: Execute declarative joins across relational databases (PostgreSQL, MySQL, SQLite), document stores (MongoDB), and key-value stores (Redis) in one query.
- Read-Only Safety: Lexical and AST validation reject mutation operations (
INSERT,UPDATE,DELETE,DROP,ALTER, etc.) before any network connection or query execution occurs. - In-Memory SQLite Staging: Uses an ephemeral in-memory SQLite database (
sqlite3.openInMemory()) to stage intermediate datasets and compute relational joins. - DAG Execution Planner: Constructs dependency graphs to schedule independent queries in parallel while throttling concurrent connections per stage (default batch limit: 3).
- Command-Line Interface: Run queries, inspect execution plans, lint scripts, or launch a Language Server Protocol (LSP) daemon (
ttql lint,ttql plan,ttql run,ttql lsp).
📚 Documentation
- 🌐 Online Documentation Portal: Official TableTalk & TTQL guides, tutorials, and interactive examples.
- ⚡ Developer Syntax Guide: Rich, developer-friendly cheat sheet, pipeline diagrams, operators, and copy-paste recipes.
- 📖 Official Language Manual & Specification: Comprehensive reference manual, pushdown mechanics, and formal EBNF grammar.
- 🏛️ Compiler Architecture Wiki: Deep dive into the frontend compiler, DAG optimizer, and ephemeral staging engine.
Installation
Via Pub
dart pub global activate ttql
From Source
git clone https://github.com/Dud3core-webdev/TTQL.git
cd TTQL
dart pub get
Command Line Usage
The ttql executable provides commands for validation, inspection, and execution:
1. Static Linting (ttql lint)
Validates script syntax and checks for forbidden mutation keywords without connecting to any database:
ttql lint path/to/script.ttql
2. Execution Plan Inspection (ttql plan)
Displays the Directed Acyclic Graph (DAG) stages, target database engines, and staging tables:
ttql plan path/to/script.ttql
3. Query Execution (ttql run)
Executes the query script and formats the results:
# Tabular output
ttql run path/to/script.ttql --config connections.json --format table
# JSON output
ttql run path/to/script.ttql --config connections.json --format json
# CSV export
ttql run path/to/script.ttql --config connections.json --format csv > results.csv
4. Language Server Protocol (ttql lsp)
Starts the JSON-RPC 2.0 Language Server over standard input/output (stdio) for IDE diagnostics and completion:
ttql lsp
Connection Configuration (--config)
Query execution requires a JSON configuration file specifying connection strings or offline mock data:
{
"connections": [
{
"id": "ecommerce_pg",
"name": "PostgreSQL E-Commerce",
"engine": "postgres",
"connectionString": "postgres://${PG_USER}:${PG_PASS}@localhost:5432/ecommerce_pg",
"schemaOverview": {
"customers": ["customer_id", "full_name", "email"]
},
"mockData": [
{ "customer_id": "cust_101", "full_name": "Alice Vance", "email": "alice@tabletalk.io" },
{ "customer_id": "cust_102", "full_name": "Bob Smith", "email": "bob.smith@techcorp.dev" }
]
}
]
}
- Environment Variable Expansion:
${VAR_NAME}placeholders in connection strings are resolved from the environment at runtime. - Offline Mock Execution: Defining
mockDataallows evaluating scripts and testing joins without live database connections.
Editor Support
Syntax highlighting, diagnostic linting, and completion support for VS Code and compatible editors is available in the TTQL VS Code Extension.
Programmatic Usage in Dart
package:ttql can be integrated directly into Dart applications:
import 'package:ttql/ttql.dart';
void main() async {
final script = '''
const pg = environment.connections.ecommerce_pg;
const mysql = environment.connections.inventory_mysql;
const targetCustomer = 'cust_101';
const customerFields = ['customer_id', 'full_name', 'email'];
from(pg.customers)
.select([...customerFields])
.where(customer_id == targetCustomer)
.innerJoin(mysql.shipments, on: 'customer_id')
.select('shipment_id', 'order_id')
.orderBy(customer_id, 'ASC')
.limit(10);
''';
final engine = TtqlEngine(connectionProvider: myConnectionProvider);
final result = await engine.executeScript(script);
for (final row in result.rows) {
print(row);
}
}
Fluent Query Pipeline
TTQL features an ergonomic fluent chaining pipeline:
const pg = environment.connections.ecommerce_pg;
const mysql = environment.connections.inventory_mysql;
from(pg.customers as c)
.innerJoin(mysql.shipments as s, on: c.customer_id == s.customer_id)
.where(s.status == 'in_transit' && c.country == 'US')
.groupBy(c.country)
.select([
c.country,
count() as shipment_count
])
.having(shipment_count > 5)
.orderBy(shipment_count, 'DESC')
.limit(20)
.offset(0);
For the exhaustive specification, formal EBNF grammar, and real-world recipes, read the Official TTQL Language Manual.
Architecture Documentation
For details on the compiler pipeline, AST representation, DAG planner, and staging database:
- Official TTQL Language Manual - The complete language specification and cookbook.
- Architecture Wiki Index
License
MIT License. See LICENSE for details.
Libraries
- compiler/compiler
- TTQL Compiler Subsystem (Frontend Lexer, Parser & AST Models).
- connectors/connectors
- TTQL Connectors & Environment Context Subsystem.
- constants/ttql_constants
- dialects/dialects
- TTQL Query Dialects & Expression Visitors Subsystem.
- formatters/cli_result_formatter
- models/cli_connection_descriptor
- models/db_engine_registry
- models/db_engine_type
- models/ttql_ast_node
- models/ttql_binary_logical_expression
- models/ttql_comparison_expression
- models/ttql_connection_descriptor
- models/ttql_dependency_binding
- models/ttql_diagnostic
- models/ttql_environment_context
- models/ttql_exceptions
- models/ttql_execution_result
- models/ttql_expression
- models/ttql_group_expression
- models/ttql_inferred_type
- models/ttql_join_node
- models/ttql_order_by_node
- models/ttql_planned_step
- models/ttql_projection_item
- models/ttql_query_invocation_node
- models/ttql_query_plan
- models/ttql_scope_range
- models/ttql_script_node
- models/ttql_suggestion
- models/ttql_suggestion_kind
- models/ttql_token
- models/ttql_unary_logical_expression
- models/ttql_where_predicate_node
- planner/planner
- TTQL Planner Subsystem (DAG Scheduling & Dependency Bindings).
- runtime/runtime
- TTQL Runtime & Ephemeral Staging Subsystem.
- services/cli_connection_provider
- services/lsp/json_rpc_transport
- services/lsp/lsp_document_store
- services/translators/mongo_expression_visitor
- services/translators/mongo_query_dialect
- services/translators/query_dialect_strategy
- services/translators/redis_query_dialect
- services/translators/sql_expression_visitor
- services/translators/sql_query_dialect
- services/ttql_connection_provider
- services/ttql_dag_planner
- services/ttql_engine
- services/ttql_environment_builder
- services/ttql_ephemeral_staging_database
- services/ttql_lexer
- services/ttql_linter
- services/ttql_lsp_server
- services/ttql_parser
- tooling/tooling
- TTQL Developer Tooling, Linter, Formatters & Language Server Protocol (LSP) Subsystem.
- ttql
- TableTalk Query Language (TTQL) Core Engine & Parser.