1- //! Rust-Postgres is a pure-Rust frontend for the popular PostgreSQL database. It
2- //! exposes a high level interface in the vein of JDBC or Go's `database/sql`
3- //! package.
1+ //! A pure-Rust frontend for the popular PostgreSQL database.
42//!
53//! ```rust,no_run
64//! extern crate postgres;
@@ -1036,10 +1034,11 @@ impl Connection {
10361034 /// # use postgres::{Connection, SslMode};
10371035 /// # let x = 10i32;
10381036 /// # let conn = Connection::connect("", SslMode::None).unwrap();
1039- /// let stmt = conn.prepare("SELECT foo FROM bar WHERE baz = $1").unwrap();
1040- /// for row in &stmt.query(&[&x]).unwrap() {
1041- /// let foo: String = row.get(0);
1042- /// println!("foo: {}", foo);
1037+ /// # let (a, b) = (0i32, 1i32);
1038+ /// # let updates = vec![(&a, &b)];
1039+ /// let stmt = conn.prepare("UPDATE foo SET bar = $1 WHERE baz = $2").unwrap();
1040+ /// for (bar, baz) in updates {
1041+ /// stmt.execute(&[bar, baz]).unwrap();
10431042 /// }
10441043 /// ```
10451044 pub fn prepare < ' a > ( & ' a self , query : & str ) -> Result < Statement < ' a > > {
@@ -1059,10 +1058,11 @@ impl Connection {
10591058 /// # use postgres::{Connection, SslMode};
10601059 /// # let x = 10i32;
10611060 /// # let conn = Connection::connect("", SslMode::None).unwrap();
1062- /// let stmt = conn.prepare_cached("SELECT foo FROM bar WHERE baz = $1").unwrap();
1063- /// for row in &stmt.query(&[&x]).unwrap() {
1064- /// let foo: String = row.get(0);
1065- /// println!("foo: {}", foo);
1061+ /// # let (a, b) = (0i32, 1i32);
1062+ /// # let updates = vec![(&a, &b)];
1063+ /// let stmt = conn.prepare_cached("UPDATE foo SET bar = $1 WHERE baz = $2").unwrap();
1064+ /// for (bar, baz) in updates {
1065+ /// stmt.execute(&[bar, baz]).unwrap();
10661066 /// }
10671067 /// ```
10681068 pub fn prepare_cached < ' a > ( & ' a self , query : & str ) -> Result < Statement < ' a > > {
0 commit comments