Skip to content

Commit 39ac420

Browse files
Merge pull request #32 from theseus-rs/update-postgres-example
chore: update use of settings of postgres connection and correct typo in output
2 parents 9c95ede + f50a91b commit 39ac420

File tree

1 file changed

+9
-7
lines changed
  • examples/postgres_embedded/src

1 file changed

+9
-7
lines changed

examples/postgres_embedded/src/main.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,22 @@ fn main() -> Result<()> {
1010
let database_name = "test";
1111
postgresql.create_database(database_name)?;
1212
let settings = postgresql.settings();
13-
let host = settings.host.to_string();
14-
let port = settings.port.to_string();
15-
let username = settings.username.to_string();
16-
let password = settings.password.to_string();
17-
1813
let mut client = Client::connect(
19-
format!("host={host} port={port} user={username} password={password}").as_str(),
14+
format!(
15+
"host={host} port={port} user={username} password={password}",
16+
host = settings.host,
17+
port = settings.port,
18+
username = settings.username,
19+
password = settings.password
20+
)
21+
.as_str(),
2022
NoTls,
2123
)?;
2224

2325
println!("Creating table 'todos'");
2426
create_table_todo(&mut client)?;
2527

26-
let description = "Implement embedded database with sqlx";
28+
let description = "Implement embedded database with postgres";
2729
println!("Adding new todo with description '{description}'");
2830
let todo_id = add_todo(&mut client, description)?;
2931
println!("Added new todo with id {todo_id}");

0 commit comments

Comments
 (0)