sqlx/examples/todos-postgres
Nicholas Connor 745c5c3957
Updated the README example with acquire connection (#99)
* Updated the README example with acquire connection

Initially from reading the docs and examples I tried to use `&mut pool` instead of `&mut conn`. The compiler gave me an error that `Pool<MySql>` didn't implement `Executor`. I had to do a bit of digging and eventually just viewed the source of `Pool` to find `acquire()`, `try_acquire()` etc.

I think this change makes it a bit easier for someone to get started.

* Update README.md to reference initial pool declaration

* Fixed compile issues and added examples of using &mut &pool
2020-01-31 23:30:08 -08:00
..
src Updated the README example with acquire connection (#99) 2020-01-31 23:30:08 -08:00
Cargo.toml Add todos CLI example for postgres 2020-01-27 10:17:58 +00:00
README.md Add todos CLI example for postgres 2020-01-27 10:17:58 +00:00
schema.sql Make "done" attribute not null 2020-01-28 15:10:09 +00:00

TODOs Example

Usage

Declare the database URL:

export DATABASE_URL="postgres://postgres@localhost/todos"

Create the database:

createdb -U postgres todos

Load the database schema:

psql -d "$DATABASE_URL" -f ./schema.sql

Run:

  • Add a todo: cargo run -- add "todo description"
  • Complete a todo: cargo run -- done <todo id>
  • List all todos: cargo run