Skip to main content

Data source management

A data source is the entry point through which APIs access databases. The platform provides unified access to heterogeneous databases through a data source driver SPI and a plugin-based design, and offers metadata browsing, read-only queries, connection pool configuration and cross-project authorization.

Supported data sources​

CategoryTypeCode
SQLMySQL / Oracle / SQL Server / PostgreSQLmysql, oracle, sqlserver, postgresql
SQLTiDB / OpenGauss / OceanBasetidb, opengauss, oceanbase
SQLDM (Dameng) / Kingbase / TDSQL / StarRocksdm, kingbase8, tdsql, starrocks
NoSQL / new typesElasticsearchelasticsearch
NoSQL / new typesTDengine / ClickHouse / DolphinDB / Hivetdengine, clickhouse, dolphindb, hive
Non-relational data sources

Data sources such as Elasticsearch and Hive do not support full standard SQL or dynamic tags such as if; the platform performs common syntax conversions at the driver layer. When table or column names contain special characters such as -, wrap them in double quotes.

Data source list​

Entry: Data Sources.

Data source management

The list shows basic information and status for data sources and supports:

  • Filtering by type and searching by name.
  • Creating, editing and deleting data sources.
  • Testing connections and enabling/disabling data sources.
  • Expanding the metadata tree to browse databases, tables and columns.
  • Authorizing data sources for use by other projects.

Data permissions: you can only see data sources you created and data sources you have been authorized to access.

Add a data source​

  1. Click Create and select the data source type.
  2. Fill in the connection information:
FieldDescription
Data source nameDisplay name; we recommend including the environment or business identifier
Host / portDatabase host and port
Database / schemaDefault database or schema
Username / passwordConnection account; the password is stored encrypted
Connection parametersAdditional JDBC parameters provided by the database type
Connection poolMinimum idle connections, maximum connections, maximum lifetime, keepalive interval, etc.
  1. Click Test Connection to verify network connectivity and credentials.
  2. After saving, the platform discovers metadata automatically.

Connection pool defaults​

ParameterDefault value
Minimum idle connections0
Maximum connection lifetime15 minutes
Keepalive probe interval2 minutes
Maximum connectionsUses the connection pool default when left blank; forced to 1 when the data source is disabled
Idle connection eviction / connection creation timeoutUses the connection pool default when left blank
Connection count planning

API calls reuse the connection pool. In high-concurrency scenarios, set an upper limit based on the database's maximum connection count to avoid multiple data sources saturating database connections at the same time.

Metadata browsing​

After a successful save, the metadata tree on the left expands in three levels: database → table → column.

  • Click a table name to open the data query page, which loads table data by default.
  • View table structures, column types and comments.
  • View the DDL script and copy it as a SQL template.
  • Refresh metadata to detect table structure changes.

Data query​

Click a table name to open the query page, which supports custom read-only SQL:

  • Only statements starting with SELECT, SHOW, DESC, DESCRIBE or EXPLAIN are allowed.
  • Query results are displayed with pagination; a single preview returns at most 100 rows.
  • SQL formatting and execution time display are supported.

See Metadata and data query.

Cross-project authorization​

Data sources can be authorized across projects:

  1. Click Authorize in the data source list.
  2. Select the target project.
  3. The authorized project can select the data source in APIs.
  4. The authorized party can only use the data; it cannot view or modify connection information or account credentials.

Limitations:

  • When a data source is referenced by APIs in other projects, you cannot revoke authorization or delete it.
  • After authorization is revoked, cross-project APIs that reference the data source must be adjusted.
  • Authorizations are maintained per data source and are not cleaned up automatically when a project is deleted; remove references first.

Security mechanisms​

MechanismDescription
Password encryptionData source passwords are stored encrypted, and APIs never return plaintext
Project isolationA data source is visible only within its own project by default
Read-only queriesThe metadata query page is restricted to read-only statements
Permission checksUsers other than the creator must be authorized to access
Connection testVerifies connectivity before saving to reduce invalid configurations

Delete and disable​

  • A data source referenced by APIs cannot be deleted directly.
  • After a data source is disabled, the connection pool maximum connection count is forced to 1, and related APIs cannot query normally.
  • Before deleting, make sure that no in-development or released APIs reference the data source.

Extend with new types​

Adding a data source type requires implementing the DataSourceDriver interface and registering it as a plugin:

public interface DataSourceDriver {
String type();
DataSource getDataSource(DataSourceConfig config);
// ...
}

The driver interface is defined in apigo-db-spi, and the generic JDBC implementation is in apigo-plugin. See Extension capabilities.

Related reading: Metadata and data query, SQL mode, Data model.