PostgreSQL Integration
Directly query your database from within an agent.
Setup
1. Ensure your Bothive instance has access to your database (allowlist IP if necessary).
2. You will need your connection string: postgres://user:pass@host:5432/db
Usage Example
bot DatabaseAnalyst {
instructions {
Analyzes user data from the production database.
}
capabilities {
postgres.query
}
on user.message {
// 1. Run a parameterized query (never string-concat user input into SQL).
call postgres.query with {
connectionString: user.db_url,
sql: "SELECT count(*) as user_count FROM users WHERE created_at > $1",
params: ["2024-01-01"]
} as result
// 2. Use the data
respond with "New users this year: " + result.rows[0].user_count
}
}
Security Note
Warning: Be careful when allowing agents to execute SQL. Always use read-only users where possible, or strictly scope the connection permissions.