I am trying to connect to a database:
extern crate tokio; // 0.2.6, features = ["full"]
extern crate tokio_postgres; // 0.5.1
use futures::executor;
use tokio_postgres::NoTls;
fn main() {
let fut = async {
let (client, connection) = match tokio_postgres::connect("actual stuff", NoTls).await {
Ok((client, connection)) => (client, connection),
Err(e) => panic!(e),
};
tokio::spawn(async move {
if let Err(e) = connection.await {
eprintln!("connection error: {}", e);
}
});
let rows = match client
.query(
"SELECT $1 FROM planet_osm_point WHERE $1 IS NOT NULL LIMIT 100",
&[&"name"],
)
.await
{
Ok(rows) => rows,
Err(e) => panic!(e),
};
let names: &str = rows[0].get("name");
println!("{:?}", names);
};
executor::block_on(fut);
println!("Hello, world!");
}
It compiled, but when I ran it, I received the error message
thread 'main' panicked at 'no current reactor'