Skip to content

Managing Datasources

Datasources are the connectors that pull data from your internal systems into Thoth.

Types of Datasources

1. JDBC (SQL Database)

Connect directly to your relational databases.

  • Supported Databases: PostgreSQL, MySQL, MariaDB, Oracle, SQL Server, H2.

  • Configuration:

    • JDBC URL: The connection string (e.g., jdbc:postgresql://localhost:5432/mydb).
    • Credentials: Username and Password (stored securely in Thoth Secrets).
    • SQL Query: The query to execute. You can use parameters using the colon syntax: SELECT * FROM users WHERE id = :user_id.
  • Post-processing: You can optionally provide a Groovy script to transform the SQL result set before it's returned.

2. REST (Web API)

Fetch data from internal microservices or external SaaS APIs.

  • Method: GET, POST, PUT, DELETE, etc.

  • URL: The endpoint URL. Supports parameters: https://api.example.com/v1/users/{id}.

  • Headers & Cookies: JSON objects defining required authentication or metadata.

  • Body: For POST/PUT requests, define the JSON payload.

  • Post-processing: Use a Groovy script to parse complex JSON responses into the flat structure needed by the renderer.

3. SCRIPT (Groovy)

The most flexible option. Write custom logic to generate data or combine multiple sources.

  • Language: Apache Groovy.

  • Context: The script has access to any input parameters passed to it.

  • Return Value: The script must return a Map or a List of Maps.

Input Parameters

Thoth automatically detects required inputs from your configurations:

  • JDBC: Any :name in the SQL.

  • REST: Any {name} in the URL, Body, or Headers.

  • SCRIPT: Any variable used in the Groovy script.

Output Properties

After configuring a datasource, use the Test Connection button.

  1. Provide sample values for the detected input parameters.
  2. Run the test.
  3. If successful, Thoth will display the returned data and automatically populate the Output Properties list.
  4. These output properties are what you will map to your templates in the Renderer.

Secrets Integration

Never hardcode passwords or API keys in the datasource configuration. Instead:

  1. Go to the Secrets section.
  2. Create a new secret (e.g., DB_PASSWORD).
  3. In the Datasource configuration, use the secret selector to link the password field to your stored secret.
  4. Secrets are encrypted at rest using AES-256.