File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -816,6 +816,29 @@ impl PostgresConnection {
816816 conn. prepare ( query, self )
817817 }
818818
819+ /// Creates a new COPY FROM STDIN prepared statement.
820+ ///
821+ /// These statements provide a method to efficiently bulk-upload data to
822+ /// the database.
823+ ///
824+ /// ## Example
825+ ///
826+ /// ```rust,no_run
827+ /// # use postgres::{PostgresConnection, NoSsl};
828+ /// # use postgres::types::ToSql;
829+ /// # let _ = || {
830+ /// # let conn = PostgresConnection::connect("", &NoSsl).unwrap();
831+ /// try!(conn.execute("CREATE TABLE foo (
832+ /// bar INT PRIMARY KEY,
833+ /// baz VARCHAR
834+ /// )", []));
835+ ///
836+ /// let stmt = try!(conn.prepare_copy_in("foo", ["bar", "baz"]));
837+ /// let data: &[&[&ToSql]] = &[&[&0i32, &"blah".to_string()],
838+ /// &[&1i32, &None::<String>]];
839+ /// try!(stmt.execute(data.iter().map(|r| r.iter().map(|&e| e))));
840+ /// # Ok(()) };
841+ /// ```
819842 pub fn prepare_copy_in < ' a > ( & ' a self , table : & str , rows : & [ & str ] )
820843 -> PostgresResult < PostgresCopyInStatement < ' a > > {
821844 let mut conn = self . conn . borrow_mut ( ) ;
You can’t perform that action at this time.
0 commit comments