mirror of
https://github.com/catdevnull/preciazo.git
synced 2024-11-22 14:16:19 +00:00
db: arreglar init
This commit is contained in:
parent
7e09c65012
commit
cc7a5789fa
1 changed files with 3 additions and 1 deletions
|
@ -5,6 +5,7 @@ use std::{
|
|||
};
|
||||
|
||||
use sqlx::{sqlite::SqliteConnectOptions, SqlitePool};
|
||||
use tracing::info;
|
||||
|
||||
use crate::{best_selling::BestSellingRecord, PrecioPoint};
|
||||
|
||||
|
@ -16,10 +17,11 @@ pub struct Db {
|
|||
impl Db {
|
||||
pub async fn connect() -> anyhow::Result<Self> {
|
||||
let db_path = env::var("DB_PATH").unwrap_or("../sqlite.db".to_string());
|
||||
info!("Opening DB at {}", db_path);
|
||||
let pool = sqlx::pool::PoolOptions::new()
|
||||
.max_connections(1)
|
||||
.connect_with(
|
||||
SqliteConnectOptions::from_str(&db_path)?
|
||||
SqliteConnectOptions::from_str(&format!("sqlite://{}", db_path))?
|
||||
.journal_mode(sqlx::sqlite::SqliteJournalMode::Wal)
|
||||
.synchronous(sqlx::sqlite::SqliteSynchronous::Normal)
|
||||
.optimize_on_close(true, None),
|
||||
|
|
Loading…
Reference in a new issue