Skip to content

Commit

Permalink
improve example
Browse files Browse the repository at this point in the history
  • Loading branch information
olexiyb committed Jun 14, 2024
1 parent 5220a6b commit 2f4b6cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion examples/example.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use pg_embed::pg_access::PgAccess;
use pg_embed::pg_enums::PgAuthMethod;
use pg_embed::pg_fetch::{PgFetchSettings, PG_V16};
use pg_embed::postgres::{PgEmbed, PgSettings};
Expand All @@ -8,11 +9,12 @@ use std::time::Duration;

#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let cache_dir = PathBuf::from("data").join("cache");
// Postgresql settings
let pg_settings = PgSettings {
// Where to store the postgresql database
database_dir: PathBuf::from("data").join("db"),
cache_dir: Some(PathBuf::from("data").join("cache")),
cache_dir: Some(cache_dir.clone()),
port: 5432,
user: "postgres".to_string(),
password: "password".to_string(),
Expand Down Expand Up @@ -61,6 +63,7 @@ async fn main() -> Result<(), Box<dyn Error>> {

// stop postgresql database
pg.stop_db().await?;
PgAccess::purge(&cache_dir)?;

Ok(())
}
3 changes: 1 addition & 2 deletions src/postgres.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ use std::time::Duration;

use futures::TryFutureExt;
use log::{error, info};
use tokio::sync::Mutex;

#[cfg(feature = "rt_tokio_migrate")]
use sqlx_tokio::migrate::{MigrateDatabase, Migrator};
#[cfg(feature = "rt_tokio_migrate")]
use sqlx_tokio::postgres::PgPoolOptions;
#[cfg(feature = "rt_tokio_migrate")]
use sqlx_tokio::Postgres;
use tokio::sync::Mutex;

use crate::command_executor::AsyncCommand;
use crate::pg_access::PgAccess;
Expand Down

0 comments on commit 2f4b6cc

Please sign in to comment.