I am new to Rust, Postgres, and trying to build a small utility to connected to Postgres database. Below is the code:
#![allow(unused_variables)]
use postgres::{Client, Error, NoTls};
fn main() -> Result<(), Error> {
// let mut client = db_utils::connect()?;
let client = Client::connect(
"postgresql://postgres:postgres@localhost:5432/postgres",
NoTls
)?;
Ok(())
}
And the Error is:
Error: Error { kind: Db, cause: Some(DbError { severity: "FATAL", parsed_severity: Some(Fatal), code: SqlState(E28P01), message: "password authentication failed for user \"postgres\"", detail: None, hint: None, position: None, where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("auth.c"), line: Some(335), routine: Some("auth_failed") }) }
I understand that user 'postgres' doesn't have any password, but if I remove ":postgress" then it fails with error Error: Error { kind: Config, cause: Some("password missing") }
I tried creating another user on Postgres with password but no luck.
Please help, any pointers?