Introduction
Executing database queries within Canonic workflows allows for dynamic interaction with your database. Whether you're fetching, updating, or inserting data, you can seamlessly integrate these actions within your workflows.
Setting Up Database Queries
To execute database queries within a Canonic workflow:
1. Add a DB Query Node
- Placement: Determine where in your workflow you need to query your database.
- Add Node: Add a DB Query node at the chosen point.
2. Configure the Query
- Select Database: Choose the database you're querying (e.g., MongoDB, MySQL).
-
Write Query: Input your SQL or NoSQL query in the node's configuration.
- Example for SQL:
SELECT * FROM users WHERE last_login > '2024-01-01'
. - Example for NoSQL:
{ "lastLogin": { "$gt": "2024-01-01" } }
.
- Example for SQL:
3. Authenticate
- Connection Details: Provide necessary authentication details like connection strings, usernames, and passwords.
Testing and Validation
- Input Test Data: Use realistic test data to simulate the database queries.
- Execute Workflow: Run the workflow and observe the execution of your database queries.
- Analyze Results: Check the outputs and ensure the query results are as expected.
Best Practices
- Optimize Queries: Ensure your queries are efficient, especially for large datasets.
Note: Efficiently executing database queries within Canonic workflows enhances your data manipulation capabilities. Proper setup, testing, and adherence to best practices ensure successful database interactions.