Skip to content

Supported Data Sources

Data Source Support List

DataBars adopts a plug-in architecture design, loading data sources through plugins. This design gives the system high extensibility, theoretically supporting any type of data source. When new data source support is needed, simply develop the corresponding plugin to integrate it into the system.

NameSupported
MysqlYes
MariaDBYes
PostgreDBYes
H2Yes
MongoYes
RedisYes
OracleUnder Development
SqlServerUnder Development
GuassDBUnder Development
DamengUnder Development
DB2Under Development
PrestoSQLUnder Development
TrinoUnder Development
NebulaUnder Development
TidbUnder Development
ESUnder Development
KafkaUnder Development

Data Source Syntax Support

Mysql

MySQL supports querying using SQL (Structured Query Language), which is the standard language for performing database operations. It is typically divided into three categories: DDL, DML, and queries. MySQL also includes some other statement categories, such as replication. For the components of SQL syntax, please refer to: Mysql SQL Official Documentation.

  1. DDL (Data Definition Language) Used to define database objects such as databases, tables, views, and indexes. Common DDL statements are:
  • CREATE: Create database, table, and other objects.
    sql
    CREATE DATABASE test_db;
    CREATE TABLE users (id INT, name VARCHAR(50));
  • ALTER: Modify the structure of database, table, and other objects.
    sql
    ALTER TABLE users ADD COLUMN age INT;
  • DROP: Delete database, table, and other objects.
    sql
    DROP TABLE users;
  1. DML (Data Manipulation Language) Used to perform insert, delete, and update operations on data in the database. Common DML statements are:
  • INSERT: Insert data into a table.
    sql
    INSERT INTO users (id, name, age) VALUES (1, 'Alice', 25);
  • UPDATE: Modify data in a table.
    sql
    UPDATE users SET age = 26 WHERE id = 1;
  • DELETE: Delete data from a table.
    sql
    DELETE FROM users WHERE id = 1;
  1. Query Statements Used to retrieve data from the database. Common query statements are:
  • SELECT: Basic query statement.
    sql
    SELECT * FROM users;
  • Conditional Query: Use the WHERE clause to filter data.
    sql
    SELECT * FROM users WHERE age > 20;
  • Sorting Query: Use the ORDER BY clause to sort the results.
    sql
    SELECT * FROM users ORDER BY age DESC;
  1. Replication-Related Statements Replication in MySQL is used to achieve data backup and read - write separation. Common replication - related statements are:
  • CHANGE MASTER TO: Configure master - slave replication parameters.
    sql
    CHANGE MASTER TO 
        MASTER_HOST='master_host',
        MASTER_USER='replication_user',
        MASTER_PASSWORD='password';
  • START SLAVE: Start the slave server replication process.
    sql
    START SLAVE;

MariaDB

Same as MySQL

Redis

Redis uses the Lua language as its script execution environment. This design allows users to perform complex multi-command operations on the Redis server while ensuring atomic execution. The application of Lua scripts in Redis provides powerful data processing capabilities while maintaining high-efficiency execution.

Basic Syntax Structure Lua scripts in Redis follow the standard Lua syntax but add some Redis-specific functions:

Example 1: Calculate the sum of two keys

lua
-- Example script: Calculate the sum of two keys
local key1 = KEYS[1]
local key2 = KEYS[2]
local val1 = redis.call('GET', key1)
local val2 = redis.call('GET', key2)
return val1 + val2

Example 2: Implement counter functionality

lua
-- Example script: Implement counter functionality
local key = KEYS[1]
local increment = tonumber(ARGV[1]) or 1
local current = tonumber(redis.call('GET', key) or '0')
local result = current + increment
redis.call('SET', key, result)
return result

Example 3: Batch set multiple key-value pairs

lua
-- Example script: Batch set multiple key-value pairs
for i = 1, #KEYS, 2 do
    local key = KEYS[i]
    local value = KEYS[i+1]
    redis.call('SET', key, value)
end
return #KEYS / 2

Redis Lua Script Official Documentation

Redis's Lua script functionality provides a powerful tool for complex data operations while maintaining Redis's concise and efficient design philosophy.

MongoDB

MongoDB uses JavaScript as its query language, providing powerful scripting capabilities. The MongoDB Shell is an interactive JavaScript environment that allows users to perform various database operations.

Basic Query Syntax

1. Simple Query

javascript
// Find all documents
db.collection.find()

// Find documents with specific field matching
db.collection.find({ field: "value" })

2. Conditional Query

javascript
// Find documents with age greater than 18
db.collection.find({ age: { $gt: 18 } })

// Find documents with age greater than or equal to 18 and less than 30
db.collection.find({ age: { $gte: 18, $lt: 30 } })

// Find documents with name equal to Alice or Bob
db.collection.find({ name: { $in: ["Alice", "Bob"] } })

3. Projection Query

javascript
// Only return the name field, not the _id field
db.collection.find({}, { name: 1, _id: 0 })

// Return name and age fields, not the _id field
db.collection.find({}, { name: 1, age: 1, _id: 0 })

4. Sort Query

javascript
// Sort by age field in ascending order
db.collection.find().sort({ age: 1 })

// Sort by age field in descending order
db.collection.find().sort({ age: -1 })

5. Limit Query Results

javascript
// Only return the first 5 documents
db.collection.find().limit(5)

// Skip the first 5 documents and return the next 10 documents
db.collection.find().skip(5).limit(10)

6. Aggregation Query

javascript
// Group by age field and count the number of documents for each age
db.collection.aggregate([
  { $group: { _id: "$age", count: { $sum: 1 } } }
])

// Calculate the average age of all documents
db.collection.aggregate([
  { $group: { _id: null, avgAge: { $avg: "$age" } } }
])

H2

H2 is a lightweight open-source embedded relational database written in Java, supporting both in-memory and persistent modes, and providing standard SQL syntax support.

Basic SQL Examples:

sql
-- Create table
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(50));

-- Insert data
INSERT INTO users VALUES (1, 'Alice');

-- Query data
SELECT * FROM users;

Connection Methods:

  • In-memory mode: jdbc:h2:mem:test
  • Persistent mode: jdbc:h2:~/test
  • Server mode: jdbc:h2:tcp://localhost/~/test

H2 Official Documentation

浙ICP备2025189648号-1