From 6fda24186bd87b43e8bbf69dca78a0fbdc08f13e Mon Sep 17 00:00:00 2001 From: Edward Shen Date: Thu, 22 Apr 2021 13:18:50 -0400 Subject: [PATCH] use debug logging level for sql statements --- src/cache/low_mem.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/cache/low_mem.rs b/src/cache/low_mem.rs index c84414a..93cd60f 100644 --- a/src/cache/low_mem.rs +++ b/src/cache/low_mem.rs @@ -1,11 +1,13 @@ //! Low memory caching stuff +use std::str::FromStr; use std::sync::{atomic::Ordering, Arc}; use std::{path::PathBuf, sync::atomic::AtomicU64}; use async_trait::async_trait; use futures::StreamExt; -use sqlx::SqlitePool; +use log::LevelFilter; +use sqlx::{sqlite::SqliteConnectOptions, ConnectOptions, SqlitePool}; use tokio::sync::mpsc::{channel, unbounded_channel, Sender, UnboundedSender}; use tokio_stream::wrappers::ReceiverStream; @@ -33,11 +35,12 @@ impl LowMemCache { let (file_size_tx, mut file_size_rx) = unbounded_channel(); let (db_tx, db_rx) = channel(128); let db_pool = { - let db_url = format!( - "sqlite:{}/metadata.sqlite?mode=rwc", - disk_path.to_str().unwrap() - ); - let db = SqlitePool::connect(&db_url).await.unwrap(); + let db_url = format!("sqlite:{}/metadata.sqlite", disk_path.to_str().unwrap()); + let mut options = SqliteConnectOptions::from_str(&db_url) + .unwrap() + .create_if_missing(true); + options.log_statements(LevelFilter::Debug); + let db = SqlitePool::connect_with(options).await.unwrap(); // Run db init sqlx::query_file!("./db_queries/init.sql")