title: Rust and PostgreSQL with tokio_postgres
body: <p>I have a PostgreSQL database with one simple table:</p>
  <pre class="lang-sql prettyprint-override"><code>CREATE DATABASE test_database;
  \c test_database;
  CREATE TABLE users ( id int primary key NOT NULL, name varchar(40) NOT NULL );
  INSERT INTO users (id,name) VALUES (1, 'user_one');
  INSERT INTO users (id,name) VALUES (2, 'user_two');
  </code></pre>
  <p>Now I want to write a rust program that retrieves users with <code>SELECT id, name FROM users</code> and returns them.
  For this I picked <code>tokio_postgres</code>, as it is asynchronous and it seems to have support with Tokio async runtime.</p>
  <p>This is my program:</p>
  <pre class="lang-rust prettyprint-override"><code>mod domain;
  mod types;
  use tokio_postgres::NoTls;
  use types::AsyncResult;
  
  // Using Tokio runtime for async behaviour: https://crates.io/crates/tokio
  #[tokio::main]
  async fn main() -&gt; AsyncResult&lt;()&gt; {
    // Get DB client and connection
    let (client, connection) = tokio_postgres::connect(
      &quot;postgres://test_user:secret_password@localhost/test_database&quot;,
      NoTls,
    )
    .await?;
  
    // Spawn connection
    tokio::spawn(async move {
      if let Err(error) = connection.await {
        eprintln!(&quot;Connection error: {}&quot;, error);
      }
    });
  
    // Do the query
    let users = client.query(&quot;SELECT id, name FROM users&quot;, &amp;[]).await?;
  
    println!(&quot;{:#?}&quot;, users);
  
    Ok(())
  }
  
  </code></pre>
  <p>From this I expect to get something similar to:</p>
  <pre class="lang-json prettyprint-override"><code>[
    {
      &quot;id&quot;: 1,
      &quot;name&quot;: &quot;user_1&quot;
    },
    {
      &quot;id&quot;: 2,
      &quot;name&quot;: &quot;user_2&quot;
    }
  ]
  </code></pre>
  <p>But instead I receive the table structure:</p>
  <pre><code>[
    Row {
      columns: [
        Column {
          name: &quot;id&quot;,
          type: Int4,
        },
        Column {
          name: &quot;name&quot;,
          type: Varchar,
        },
      ],
    },
    Row {
      columns: [
        Column {
          name: &quot;id&quot;,
          type: Int4,
        },
        Column {
          name: &quot;name&quot;,
          type: Varchar,
        },
      ],
    },
  ]
  </code></pre>
  <p>I tried everything, but I cant't see what I'm doing wrong.</p>