Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
894 B · 25 lines
Rust
at dev
1234567891011121314151617181920212223242526//! SQLite AppView index (docs/03): everything the system *concluded*, plus//! mirrors of what users *said*, keyed by AT-URI. Clean seam to Postgres://! plain SQL, no SQLite-isms beyond UPSERT.
use sqlx::sqlite::{SqliteConnectOptions, SqliteJournalMode, SqlitePoolOptions};use sqlx::SqlitePool;use std::str::FromStr;
pub async fn open(db_path: &str) -> anyhow::Result<SqlitePool> { let opts = SqliteConnectOptions::from_str(&format!("sqlite://{db_path}"))? .create_if_missing(true) .journal_mode(SqliteJournalMode::Wal) .busy_timeout(std::time::Duration::from_secs(10)) .foreign_keys(false); let pool = SqlitePoolOptions::new() .max_connections(8) .connect_with(opts) .await?; sqlx::migrate!("./migrations").run(&pool).await?; Ok(pool)}
pub fn now() -> i64 { time::OffsetDateTime::now_utc().unix_timestamp()}