Files
caravel/backend/src/db.rs
T
2026-02-25 13:11:25 -08:00

16 lines
384 B
Rust

use anyhow::Result;
use sqlx::{migrate::Migrator, sqlite::SqlitePoolOptions, SqlitePool};
static MIGRATOR: Migrator = sqlx::migrate!("./migrations");
pub async fn init_pool(database_url: &str) -> Result<SqlitePool> {
let pool = SqlitePoolOptions::new()
.max_connections(5)
.connect(database_url)
.await?;
MIGRATOR.run(&pool).await?;
Ok(pool)
}