Integrating a high-speed, object-oriented database with traditional reporting tools, BI dashboards, or legacy applications often hits a familiar roadblock: most external tools expect SQL.
With the new MySQL Endpoint module (module-go-mysqlendpoint), ThingsDB can now speak the MySQL wire protocol directly. This allows you to connect standard MySQL clients, BI tools (like Grafana, Metabase, or Power BI), and existing SQL drivers straight to your ThingsDB collections, no ETL pipelines or data duplication required.
High Availability Out of the Box
Because ThingsDB modules run across every node in your cluster, the MySQL endpoint is automatically available on all ThingsDB nodes. Since every node reads directly from the synchronized cluster state, you get built-in high availability and load-balancing capabilities for your SQL connections right out of the box.
Quick Setup
Installing and configuring the module takes just a few lines in the @thingsdb scope:
// 1. Install the module
new_module('mysqlendpoint', 'github.com/thingsdb/module-go-mysqlendpoint');
// 2. Restrict usage to the @thingsdb scope (recommended)
set_module_scope('mysqlendpoint', '/t');
// 3. Configure with a valid token (requires QUERY + CHANGE privileges)
set_module_conf('mysqlendpoint', {
thingsdb_token: '<YOUR TOKEN>',
});
By default, the module listens on port 3306 and automatically creates a dedicated schema collection (configurable via schema_scope) where you define your virtual MySQL database, tables, columns, and users.
How It Works: Virtual Tables & Row Mode
Rather than forcing your ThingsDB data into rigid SQL tables on disk, the module lets you map ThingsDB queries to virtual MySQL tables:
-
Column Definitions: You define standard SQL column types (
TINYTEXT,TEXT,FLOAT32, primary keys, and foreign keys) inside theschemacollection so external tools can introspect your schema just like a real MySQL server. -
Backed by ThingsDB Queries: Each table defines
allandcountqueries that return rows matching your column order. This pairs naturally with ThingsDB's Row Mode (mod_type(..., 'row', [...])), allowing procedures like.articles.map_wrap()to stream compact value arrays straight to the MySQL endpoint with minimal overhead.
Whenever you update your virtual schema in the schema collection, simply call mysqlendpoint.reload() to apply the changes without restarting your nodes. You can find a complete example in the repository.
Flexible Multi-Tenant & User-Aware Queries
One of the biggest advantages of exposing ThingsDB via virtual queries is how cleanly you can handle multi-tenancy and per-user data isolation within a single database:
-
Dynamic Scope Resolution: A ThingsDB
scopecan be configured on a User, a Table, or both. If a table doesn't specify a fixed scope, queries automatically route to the collection assigned to the logged-in MySQL user. Meanwhile, tables with a fixed scope (such as shared lookup tables) serve global data to everyone. -
Row-Level Filtering via username: Every
allandcountquery is executed with an injectedusernamevariable containing the authenticated MySQL user's name. Even when multiple users share the exact same underlying collection, you can dynamically filter results or compute user-specific values right inside your ThingsDB procedure.
Get Started
Whether you want to plug a BI dashboard into live cluster metrics or give external services read access to isolated tenant collections, the MySQL Endpoint module bridges the gap with minimal setup.
Check out the full documentation, configuration options, and a complete runnable example in the module-go-mysqlendpoint repository.
Top comments (0)