Get Database Schema

Get a database's tables and columns so the assistant can write correct SQL.

Tool: draxlr_get_database_schema

Returns a database's schema — its tables and their columns (with data types) — so your assistant can write correct SQL. Your assistant will typically call this before Run Query. Only the tables you have access to are returned, and SQL should reference the table name and column name (not the display names).

Parameters

ParameterTypeRequiredDescription
databaseIdstringYesThe database id (from List Databases)

Example

"What tables are in my Sales DB?" — or just ask a data question and the assistant will fetch the schema itself.

Arguments:

{
  "databaseId": "665f1c2a9b1e4a0012ab34cd"
}

Response

{
  "databaseId": "665f1c2a9b1e4a0012ab34cd",
  "tableCount": 2,
  "tables": [
    {
      "name": "orders",
      "displayName": "Orders",
      "schema": "public",
      "columns": [
        { "name": "id", "type": "integer" },
        { "name": "status", "type": "text" },
        { "name": "total", "type": "numeric" },
        { "name": "created_at", "type": "timestamp" }
      ]
    },
    {
      "name": "customers",
      "displayName": "Customers",
      "schema": "public",
      "columns": [
        { "name": "id", "type": "integer" },
        { "name": "email", "type": "text" }
      ]
    }
  ]
}
FieldDescription
tableCountNumber of tables returned
tables[].nameThe table name to use in SQL
tables[].displayNameThe friendly name shown in the Draxlr UI
tables[].schemaThe schema the table belongs to (omitted if none)
tables[].columnsThe columns, each with its name and type

Still syncing:

If the database is still syncing its tables, the tool returns an error asking you to try again shortly.