File tree Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Expand file tree Collapse file tree 1 file changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -10,23 +10,22 @@ r2d2-postgres
1010# Example
1111
1212``` rust
13- extern crate r2d2;
14- extern crate r2d2_postgres;
15- extern crate postgres;
16-
1713use std :: thread;
18- use r2d2_postgres :: {TlsMode , PostgresConnectionManager };
14+ use postgres :: {NoTls , Client };
15+ use r2d2_postgres :: PostgresConnectionManager ;
1916
2017fn main () {
21- let manager = PostgresConnectionManager :: new (" postgres://postgres@localhost" ,
22- TlsMode :: None ). unwrap ();
18+ let manager = PostgresConnectionManager :: new (
19+ " host=localhost user=postgres" . parse (). unwrap (),
20+ NoTls ,
21+ );
2322 let pool = r2d2 :: Pool :: new (manager ). unwrap ();
2423
2524 for i in 0 .. 10i32 {
2625 let pool = pool . clone ();
2726 thread :: spawn (move || {
28- let conn = pool . get (). unwrap ();
29- conn . execute (" INSERT INTO foo (bar) VALUES ($1)" , & [& i ]). unwrap ();
27+ let mut client = pool . get (). unwrap ();
28+ client . execute (" INSERT INTO foo (bar) VALUES ($1)" , & [& i ]). unwrap ();
3029 });
3130 }
3231}
You can’t perform that action at this time.
0 commit comments