File tree Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Expand file tree Collapse file tree 1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change 3
3
//! # Example
4
4
//!
5
5
//! ```no_run
6
- //! use futures::FutureExt;
7
6
//! use tokio_postgres::{NoTls, Error, Row};
8
7
//!
9
8
//! # #[cfg(not(feature = "runtime"))] fn main() {}
16
15
//!
17
16
//! // The connection object performs the actual communication with the database,
18
17
//! // so spawn it off to run on its own.
19
- //! let connection = connection.map(|r| {
20
- //! if let Err(e) = r {
18
+ //! tokio::spawn(async move {
19
+ //! if let Err(e) = connection.await {
21
20
//! eprintln!("connection error: {}", e);
22
21
//! }
23
22
//! });
24
- //! tokio::spawn(connection);
25
23
//!
26
24
//! // Now we can prepare a simple statement that just returns its parameter.
27
25
//! let stmt = client.prepare("SELECT $1::TEXT").await?;
28
26
//!
29
- //! // And then execute it, returning a Stream of Rows which we collect into a Vec .
30
- //! let rows: Vec<Row> = client
27
+ //! // And then execute it, returning a list of the resulting rows .
28
+ //! let rows = client
31
29
//! .query(&stmt, &[&"hello world"])
32
30
//! .await?;
33
31
//!
You can’t perform that action at this time.
0 commit comments