Data Connectors
The Agentic Foundry supports database connectivity through Data Connectors, allowing you to connect to and interact with different database systems for your agent workflows.
Supported Databases
Currently, the foundry supports two database types:
- PostgreSQL - Enterprise-grade relational database
- SQLite - Lightweight file-based database
- MySQL - Popular open-source relational database, widely used for web applications
- MongoDB - Leading NoSQL document database, ideal for flexible and scalable data storage
Creating Database Connections
PostgreSQL Connection
To create a new PostgreSQL connection:
- Connection Name: Enter a unique name for your connection
- Database Type: Select "PostgreSQL"
- Host: Database server hostname or IP address
- Port: Database port (default: 5432)
- Database: Database name to connect to
- Username: Database username
- Password: Database password
- Click Connect to establish the connection
Example Configuration:
Connection Name: my_postgres_db
Database Type: PostgreSQL
Host: localhost
Port: 5432
Database: myapp_production
Username: db_user
Password: ********
SQLite Connection
To create a new SQLite connection:
- Connection Name: Enter a unique name for your connection
- Database Type: Select "SQLite"
- New SQLite DB File: Specify the path to your SQLite database file
- Click Connect to establish the connection
Example Configuration:
Connection Name: my_sqlite_db
Database Type: SQLite
New SQLite DB File: database.db
MySQL Connection
To create a new MySQL connection:
- Connection Name: Enter a unique name for your connection
- Database Type: Select "MySQL"
- Host: Database server hostname or IP address
- Port: Database port
- Database: Database name to connect to
- Username: Database username
- Password: Database password
- Click Connect to establish the connection
Example Configuration:
Connection Name: mysql_db
Database Type: MySQL
Host: localhost
Port: 3306
Database: myapp_production
Username: db_user
Password: ********
MongoDB Connection
To create a new MongoDB connection:
- Connection Name: Enter a unique name for your connection
- Database Type: Select "MongoDB"
- Host: Database server hostname or IP address
- Port: Database port
- Database: Database name to connect to
- Username: Database username
- Password: Database password
- Click Connect to establish the connection
Example Configuration:
Connection Name: mongo_db
Database Type: MongoDB
Host: localhost
Port: 27017
Database: myapp_production
Username: db_user
Password: ********
Secure Credential Handling
Data Connector APIs are designed with security-first credential management:
- Secure API Integration — Data connector APIs handle credentials securely, ensuring database passwords and connection details are never exposed in plain text through the API layer.
- Base64-Encoded Passwords — Passwords are accepted as base64-encoded strings with built-in validation. The system decodes and validates the encoding before establishing any connection, rejecting malformed or incorrectly encoded values.
- Password Masking in UI — The data connector UI masks password fields at all times — during entry and when viewing existing connections — preventing accidental exposure of credentials on screen.
Data Connector Features
Run Button Functionality
The Run button in Data Connectors provides an interactive query interface:
- Select Connection Name: Choose from your active database connections
- Enter NLP Query: Write your request in natural language
- Generate Query: Click "Generate Query" to convert natural language to SQL
- Review and Edit: Examine the generated query and make modifications if needed
- Run Query: Execute the query , it will show the output
Example NLP Queries: - "Create a table called users with id, name, and email columns" - "Insert a new user with name John and email john@example.com" - "Show all users from the users table" - "Update user with id 1 to have email newemail@example.com"
Manage Button Functionality
The Manage button allows you to control your database connections:
Available Actions:
- Activate: Enable a connection for to use that in agent inferencing
- Deactivate: Disable a connection (prevents use in agents)
- Delete: Permanently remove the connection
Connection Status
A connection must be active to be used during agent inferencing. Inactive connections will not be available to agents.
Delete Warning
The delete option permanently removes the connection. This action cannot be undone.
Using Data Connectors in Agent Inferencing
Connection Requirements
When using agents that contain database tools:
- Activate Connection: Ensure the required database connection is active in Data Connectors
- Provide DB Key: Supply the connection name as the database key during inferencing
- Tool Execution: The agent will use the specified connection to fetch database information
Error Handling
If a database connection is not properly configured:
- The agent will return an error message
- No output will be produced from database-related tools
- Ensure the connection is active and the correct connection name is provided
Sample Tool Implementation
Here's an example of how to create a database tool for your agents:
def fetch_all_from_xyz(connection_name: str):
"""
Fetches all records from the 'xyz' table in the specified database using the provided database key.
Args:
connection_name (str): The key used to identify and connect to the specific database.
Returns:
list: A list of dictionaries, where each dictionary represents a row from the 'xyz' table.
"""
from MultiDBConnection_Manager import get_connection_manager
from sqlalchemy import text
try:
manager = get_connection_manager()
session = manager.get_sql_session(connection_name)
result = session.execute(text('SELECT * FROM xyz'))
rows = result.fetchall()
session.close()
return [dict(row._mapping) for row in rows]
except Exception as e:
if 'session' in locals():
session.close()
return f'Error fetching data from database {connection_name}: {str(e)}'
Important Notes for Tool Development
Required Imports
Always include these import statements in your database tools:
from MultiDBConnection_Manager import get_connection_manager
from sqlalchemy import text
Connection Manager Usage
Follow this pattern for database operations:
# Get the singleton instance of MultiDBConnectionManager
manager = get_connection_manager()
# Get a SQLAlchemy session for the specified connection
session = manager.get_sql_session(connection_name)
Session Management
Always close sessions after use:
try:
# Your database operations here
pass
except Exception as e:
# Handle errors
pass
finally:
if 'session' in locals():
session.close()
Best Practices Checklist
- No need to manually activate a connection before using it in agents; when you call
get_sql_session(connection_name), the connection will be activated automatically if theconnection_nameexists in the database. - Include required imports in your tool functions
- Always close database sessions after use