File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,13 +22,11 @@ use postgres::{Connection, SslMode};
2222struct Person {
2323 id : i32 ,
2424 name : String ,
25- data : Option <Vec <u8 >>
25+ data : Option <Vec <u8 >>,
2626}
2727
2828fn main () {
29- let conn = Connection :: connect (" postgres://postgres@localhost" , SslMode :: None )
30- . unwrap ();
31-
29+ let conn = Connection :: connect (" postgres://postgres@localhost" , SslMode :: None ). unwrap ();
3230 conn . execute (" CREATE TABLE person (
3331 id SERIAL PRIMARY KEY,
3432 name VARCHAR NOT NULL,
@@ -37,16 +35,15 @@ fn main() {
3735 let me = Person {
3836 id : 0 ,
3937 name : " Steven" . to_string (),
40- data : None
38+ data : None ,
4139 };
4240 conn . execute (" INSERT INTO person (name, data) VALUES ($1, $2)" ,
4341 & [& me . name, & me . data]). unwrap ();
44-
4542 for row in & conn . query (" SELECT id, name, data FROM person" , & []). unwrap () {
4643 let person = Person {
4744 id : row . get (0 ),
4845 name : row . get (1 ),
49- data : row . get (2 )
46+ data : row . get (2 ),
5047 };
5148 println! (" Found person {}" , person . name);
5249 }
You can’t perform that action at this time.
0 commit comments