Class DataSourceService

java.lang.Object
io.micronaut.controlpanel.panels.datasource.DataSourceService

@EachBean(DataSource.class) public class DataSourceService extends Object
Service for a specific DataSource, providing metadata about tables, columns, keys, etc.
  • Constructor Details

    • DataSourceService

      public DataSourceService(@Parameter DataSource dataSource)
  • Method Details

    • getTables

      public final List<Table> getTables()
      Retrieves a list of tables from the database, including schema, columns, primary keys, and foreign keys.
      Returns:
      List of Table metadata objects
    • generateMermaidER

      public String generateMermaidER(List<Table> tables)
      Generate a Mermaid ER diagram for the current datasource based on the provided tables metadata. It includes entities with attributes (type, size, NOT NULL) and relationships based on foreign keys.
      Parameters:
      tables - Tables discovered by getTables()
      Returns:
      Mermaid ER diagram code
    • executeQuery

      public DataSourceService.QueryResult executeQuery(String sql, int start, int length)
      Sanitize, execute and paginate a SQL query.
      Parameters:
      sql - The SQL to execute
      start - Offset of the first row
      length - Maximum number of rows to return
      Returns:
      QueryResult with column labels, rows and total row count