File tree Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Expand file tree Collapse file tree 1 file changed +18
-8
lines changed Original file line number Diff line number Diff line change @@ -11,19 +11,29 @@ Connect to CrateDB from Rust applications.
1111
1212[ postgres] is a synchronous Rust client for the PostgreSQL database.
1313
14- :::{rubric} Synopsis
14+ :::{rubric} Install
1515:::
16+ ``` shell
17+ cargo add postgres
18+ ```
1619
20+ :::{rubric} Synopsis
21+ :::
1722``` rust
1823use postgres :: {Client , NoTls };
1924
20- let mut client = Client :: connect (" host=localhost user=crate" , NoTls )? ;
21-
22- for row in client . query (" SELECT mountain, height FROM sys.summits ORDER BY height DESC LIMIT 3" , & [])? {
23- let mountain : & str = row . get (0 );
24- let height : i32 = row . get (1 );
25-
26- println! (" found mountain: {} {}" , mountain , height );
25+ fn main () -> Result <(), Box <dyn std :: error :: Error >> {
26+ let mut client = Client :: connect (" host=localhost user=crate" , NoTls )? ;
27+
28+ for row in client . query (
29+ " SELECT mountain, height FROM sys.summits ORDER BY height DESC LIMIT 3" ,
30+ & [],
31+ )? {
32+ let mountain : & str = row . get (0 );
33+ let height : i32 = row . get (1 );
34+ println! (" found mountain: {} {}" , mountain , height );
35+ }
36+ Ok (())
2737}
2838```
2939
You can’t perform that action at this time.
0 commit comments