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"
description "Analyzes user data from the production DB"
on input
// 1. Run a query
call postgres.query(
connection_string: 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
say "New users this year: " + result.rows[0].user_count
end
end
Security Note
Warning: Be careful when allowing agents to execute SQL. Always use read-only users where possible, or strictly scope the connection permissions.