- Print
- DarkLight
- PDF
Overview
The Database Call node lets you write and execute SQL queries directly within Corezoid, removing the need for writing custom APIs to access databases. With the Database Call node, managing and accessing data in your databases becomes straightforward and streamlined.
Supported databases:
- MySQL
- Microsoft SQL Server
- PostgreSQL
- Oracle
- MongoDB
To use the Database Call node, first, you need to connect your database to Corezoid.
All Database calls are made from the following IP addresses:
- 54.171.15.37/32
- 108.128.68.222/32
- 63.33.226.230/32
If you encounter access errors when calling databases, you might need to white-list these addresses.
Preparations for Working with the Database Call
- Create a database: create a database by clicking Create-Database.
- Fill in all required fields: specify all the required parameters, such as database name, users, passwords, etc. and select the database type in the drop-down list.
- Create a process: create a new process in your system and add the DB Call node to it.
- Connect the node to the database: link the DB Call node to your database by specifying the connection parameters in the Connection field.
- Execute a query: configure a query in the node. For example, select the SQL in the Language field and enter a query to retrieve information from your database.
Save changes and switch to the View mode: Click Deploy to apply all changes and switch to the View mode.
Send an empty task to your process to check its operation: In the View mode, click +New task, select Create, and click Add task to send a new empty task to your process.
Check whether your task in the final node contains information retrieved from the database.
After checking your process operation, you can configure and use your Database Call node.
Settings
The Database Call node has the following parameters:
(Optional) Title and Description: Name and details of the node.
Basic settings:
Connection: Shows the database connection
Note: For more information about how to connect your database to Corezoid, go to Examples.SQL Query: Indicates your SQL query.
Note: To access task parameters, use curly braces: {{some_parameter}}. Ensure that the query result does not surpass the maximum task size limit.Code editor: Shows the JSON format of the entered key and value. You can write and include additional code, which will be executed when a task enters the node.
Other:
- Alert if the number of tasks in the node queue reaches the following number: Helps monitor whether the number of tasks in the node exceeds the specified threshold. When selecting the checkbox, you have to enter the needed number of tasks in the field that appears below.
- Maximum interval, for which the task stays in the node before being forwarded: The amount of time a task is allowed to be in the node; can be set in seconds, minutes, hours, and days.
Note: The checkbox has a minimum value of 30 seconds. You can set a shorter interval by using the Unixtime function.
Examples
Create a table
CREATE TABLE alc ( user_id integer, conveyor_id integer, name text, description text );
Insert a new row into a table
INSERT INTO alc (user_id, conveyor_id, name, description) VALUES (13, 777000, 'Send Message', 'Use to send text messages to phone number')
Call stored function with one parameter (PostgreSQL)
SELECT function_name(arg)
Select data from two tables using JOIN
SELECT alb.conveyor_id, CONCAT('https:://api.corezoid.com/api/2/json/', alb.hash) as URL, alc.* FROM "public"."alb" alb LEFT JOIN "public"."alc" alc ON alc.conveyor_id = alb.conveyor_id WHERE alc.conveyor_id is not null
Update data based on task parameters
Change the value of the hash field with the value of {{URL}} parameter for a row with conveyor_id equals to {{conv_id}}.UPDATE alb SET hash = '{{URL}}' WHERE conveyor_id = '{{conv_id}}'
Error handling & troubleshooting
When an error occurs during the task processing, you may see the following error parameter names in the task.
Error parameter name | Parameter description |
---|---|
__conveyor_db_call_return_type_error__ | Hardware (system error), Software (error in a node logic/settings). |
__conveyor_db_call_return_type_tag__ | *Error tag. |
__conveyor_db_call_return_type_description__ | Error description in human-readable language; can be static or dynamic. |
*The error tag __conveyor_db_call_return_type_tag__
may have the following values.
Value | Cause | Solution |
---|---|---|
access_denied | You don't have permission to send a reply to the indicated Process. | Contact the Process owner for further assistance. |
access_denied | You are trying to connect to the database from another stage. | It's not allowed to connect to databases from other stages. Use the same stage to connect to the needed database. |
db_call_return_format_error | Incorrect format of the response from the Database Call node. | Contact the support team for further assistance. |
db_call_executing_error | The Database Call node returned an incorrect code. | Contact the support team for further assistance. |
not_found_conv_by_alias | Your alias refers to a Process that no longer exists. | Use an existing Process. |
db_call_fatal_error | A hardware error has occurred. | Contact the support team for further assistance. |
When working with your Process, you may encounter the following issues.
Issue | Cause | Solution |
---|---|---|
Connection to the database is lost. | The database you are trying to connect to is down. | This issue is caused by a database failure and is not related to the Corezoid platform. |
Can't reach the component that connects to the database. | The on-premise connection has been lost because the database is not functioning. | Check your database connection and credentials. |