From 23f27af737010458c1de8ebeb0582945d1241038 Mon Sep 17 00:00:00 2001 From: candywater Date: Sat, 24 Dec 2022 11:13:53 +0800 Subject: [PATCH 1/2] should add main() to newbot in rust --- postgres/src/lib.rs | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/postgres/src/lib.rs b/postgres/src/lib.rs index fbe85cbde..e97b9b0db 100644 --- a/postgres/src/lib.rs +++ b/postgres/src/lib.rs @@ -5,33 +5,33 @@ //! ```no_run //! use postgres::{Client, NoTls}; //! -//! # fn main() -> Result<(), postgres::Error> { -//! let mut client = Client::connect("host=localhost user=postgres", NoTls)?; +//! fn main() -> Result<(), postgres::Error> { +//! let mut client = Client::connect("host=localhost user=postgres", NoTls)?; //! -//! client.batch_execute(" -//! CREATE TABLE person ( -//! id SERIAL PRIMARY KEY, -//! name TEXT NOT NULL, -//! data BYTEA -//! ) -//! ")?; +//! client.batch_execute(" +//! CREATE TABLE person ( +//! id SERIAL PRIMARY KEY, +//! name TEXT NOT NULL, +//! data BYTEA +//! ) +//! ")?; //! -//! let name = "Ferris"; -//! let data = None::<&[u8]>; -//! client.execute( -//! "INSERT INTO person (name, data) VALUES ($1, $2)", -//! &[&name, &data], -//! )?; +//! let name = "Ferris"; +//! let data = None::<&[u8]>; +//! client.execute( +//! "INSERT INTO person (name, data) VALUES ($1, $2)", +//! &[&name, &data], +//! )?; //! -//! for row in client.query("SELECT id, name, data FROM person", &[])? { -//! let id: i32 = row.get(0); -//! let name: &str = row.get(1); -//! let data: Option<&[u8]> = row.get(2); +//! for row in client.query("SELECT id, name, data FROM person", &[])? { +//! let id: i32 = row.get(0); +//! let name: &str = row.get(1); +//! let data: Option<&[u8]> = row.get(2); //! -//! println!("found person: {} {} {:?}", id, name, data); +//! println!("found person: {} {} {:?}", id, name, data); +//! } +//! Ok(()) //! } -//! # Ok(()) -//! # } //! ``` //! //! # Implementation From 9d863a4ed4e2f34b1562d3217c3cf57fc18f1509 Mon Sep 17 00:00:00 2001 From: candywater Date: Sat, 24 Dec 2022 11:14:21 +0800 Subject: [PATCH 2/2] should add password as it is a common choice for connect. --- postgres/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postgres/src/lib.rs b/postgres/src/lib.rs index e97b9b0db..e5f7b8772 100644 --- a/postgres/src/lib.rs +++ b/postgres/src/lib.rs @@ -6,7 +6,7 @@ //! use postgres::{Client, NoTls}; //! //! fn main() -> Result<(), postgres::Error> { -//! let mut client = Client::connect("host=localhost user=postgres", NoTls)?; +//! let mut client = Client::connect("host=localhost user=postgres password=postgres", NoTls)?; //! //! client.batch_execute(" //! CREATE TABLE person (