n8n is a workflow automation platform with native AI capabilities, providing technical teams with the flexibility of code and the speed of no-code. With over 400 integrations, native AI features, and a fair code license, n8n allows you to build a robust automation while maintaining full control over your data and deployments.
This topic demonstrates how to build a Chat to OceanBase Database workflow template using the powerful features of n8n.
Prerequisites
You have deployed OceanBase Database and created a MySQL-compatible tenant. For more information, see Create a tenant.
This integration tutorial is performed in a Docker container. Make sure that you have set up a Docker container.
Step 1: Obtain the database connection information
Contact the deployment personnel or administrator of OceanBase Database to obtain the database connection string. For example:
obclient -h$host -P$port -u$user_name -p$password -D$database_name
Parameter description:
$host: The IP address for connecting to OceanBase Database. For connection through OceanBase Database Proxy (ODP), use the ODP address. For direct connection, use the IP address of an OBServer node.$port: The port for connecting to OceanBase Database. For connection through ODP, the default value is2883. For direct connection, the default value is2881. The port can be customized when ODP or OceanBase Database is deployed.$database_name: The name of the database to access.Notice
The user connecting to the tenant must have the
CREATE,INSERT,DROP, andSELECTprivileges on the database. For more information about user privileges, see Privilege types in MySQL-compatible mode.$user_name: The tenant account. For connection through ODP, the format isusername@tenant name#cluster nameorcluster name:tenant name:username. For direct connection, the format isusername@tenant name.$password: The account password.
For more information about the connection string, see Connect to an OceanBase tenant by using OBClient.
Step 2: Create a test table and insert data
Before you build the workflow, you need to create a sample table in OceanBase Database to store book information and insert some sample data.
CREATE TABLE books (
id VARCHAR(255) PRIMARY KEY,
isbn13 VARCHAR(255),
author TEXT,
title VARCHAR(255),
publisher VARCHAR(255),
category TEXT,
pages INT,
price DECIMAL(10,2),
format VARCHAR(50),
rating DECIMAL(3,1),
release_year YEAR
);
INSERT INTO books (
id, isbn13, author, title, publisher, category, pages, price, format, rating, release_year
) VALUES (
'database-internals',
'978-1492040347',
'"Alexander Petrov"',
'Database Internals: A deep-dive into how distributed data systems work',
'O\'Reilly',
'["databases","information systems"]',
350,
47.28,
'paperback',
4.5,
2019
);
INSERT INTO books (
id, isbn13, author, title, publisher, category, pages, price, format, rating, release_year
) VALUES (
'designing-data-intensive-applications',
'978-1449373320',
'"Martin Kleppmann"',
'Designing Data-Intensive Applications: The Big Ideas Behind Reliable, Scalable, and Maintainable Systems',
'O\'Reilly',
'["databases"]',
590,
31.06,
'paperback',
4.4,
2017
);
INSERT INTO books (
id, isbn13, author, title, publisher, category, pages, price, format, rating, release_year
) VALUES (
'kafka-the-definitive-guide',
'978-1491936160',
'["Neha Narkhede", "Gwen Shapira", "Todd Palino"]',
'Kafka: The Definitive Guide: Real-time data and stream processing at scale',
'O\'Reilly',
'["databases"]',
297,
37.31,
'paperback',
3.9,
2017
);
INSERT INTO books (
id, isbn13, author, title, publisher, category, pages, price, format, rating, release_year
) VALUES (
'effective-java',
'978-1491936160',
'"Joshua Block"',
'Effective Java',
'Addison-Wesley',
'["programming languages", "java"]',
412,
27.91,
'paperback',
4.2,
2017
);
INSERT INTO books (
id, isbn13, author, title, publisher, category, pages, price, format, rating, release_year
) VALUES (
'daemon',
'978-1847249616',
'"Daniel Suarez"',
'Daemon',
'Quercus',
'["dystopia","novel"]',
448,
12.03,
'paperback',
4.0,
2011
);
INSERT INTO books (
id, isbn13, author, title, publisher, category, pages, price, format, rating, release_year
) VALUES (
'cryptonomicon',
'978-1847249616',
'"Neal Stephenson"',
'Cryptonomicon',
'Avon',
'["thriller", "novel"]',
1152,
6.99,
'paperback',
4.0,
2002
);
INSERT INTO books (
id, isbn13, author, title, publisher, category, pages, price, format, rating, release_year
) VALUES (
'garbage-collection-handbook',
'978-1420082791',
'["Richard Jones", "Antony Hosking", "Eliot Moss"]',
'The Garbage Collection Handbook: The Art of Automatic Memory Management',
'Taylor & Francis',
'["programming algorithms"]',
511,
87.85,
'paperback',
5.0,
2011
);
INSERT INTO books (
id, isbn13, author, title, publisher, category, pages, price, format, rating, release_year
) VALUES (
'radical-candor',
'978-1250258403',
'"Kim Scott"',
'Radical Candor: Be a Kick-Ass Boss Without Losing Your Humanity',
'Macmillan',
'["human resources","management", "new work"]',
404,
7.29,
'paperback',
4.0,
2018
);
Step 3: Deploy the tools
Private deployment of n8n
n8n is a workflow automation platform based on Node.js. It provides extensive integration capabilities and flexible extensibility. By privately deploying n8n, you can better control the runtime environment of your workflows and ensure the security and privacy of your data. This section describes how to deploy n8n in a Docker environment.
sudo docker run -d --name n8n -p 5678:5678 -e N8N_SECURE_COOKIE=false n8nio/n8n
Deploy the Qwen3 model using Ollama
Ollama is an open-source AI model server that supports the deployment and management of multiple AI models. With Ollama, you can easily deploy the Qwen3 model locally to enable AI Agent functionality. This section describes how to deploy Ollama in a Docker environment, and then use Ollama to deploy the Qwen3 model.
# Deploy Ollama in a Docker environment
sudo docker run -d -p 11434:11434 --name ollama ollama/ollama
# Deploy the Qwen3 model
sudo docker exec -it ollama sh -c 'ollama run qwen3:latest'
Step 4: Build an AI Agent workflow
n8n provides a variety of nodes to build an AI Agent workflow. This section shows you how to build a Chat to OceanBase Database workflow template. The workflow consists of five nodes, and the steps are as follows:
Add a trigger
Add an HTTP trigger node to receive HTTP requests.

Add an AI Agent node
Add an AI Agent node to process AI Agent requests.

Add an Ollama Chat Model node
Select a free Ollama chat model, such as Qwen3, and configure the Ollama account.


Add a Simple Memory node
The Simple Memory node indicates short-term memory and can remember the previous five interactions in the chat.

Add a Tool node
The Tool node is used to perform database operations in OceanBase Database. Add a MySQL tool under AI Agent-tool.

Configure the MySQL tool as follows:

Click the edit icon shown in the preceding figure to configure the MySQL connection information.

After the configuration is completed, close the window. Click Test step in the upper-right corner of the configuration panel to test the database connection with a simple SQL statement, or click Back to canvas to return to the main interface.
Click Save to complete the workflow construction.
After all 5 nodes are configured, click Save to complete the workflow construction. You can then test the workflow.
Workflow demo
The completed workflow is displayed as follows:
