Skip to main content

create_pool

Function create_pool 

Source
pub async fn create_pool(db_url: Option<&str>) -> DbResult<Arc<DbPool>>
Expand description

Creates a connection pool for the database.

Initializes a connection pool with sensible defaults:

  • Max connections: 4 for file-backed SQLite, 1 for in-memory SQLite, 10 for other databases
  • Driver auto-detection: supports SQLite, PostgreSQL, MySQL
  • SQLite file mode: read-write-create for file-based databases

The pool is wrapped in Arc for thread-safe sharing across async tasks.

§Arguments

  • db_url - Optional database connection URL. Defaults to sqlite://./agentic_api.db if None. Examples: sqlite://data.db, postgresql://user:pass@host/db

§Errors

Returns sqlx::Error if:

  • Connection URL is invalid
  • Database server is unreachable
  • Connection limit is exceeded
  • Authentication fails