86 Commits

Author SHA1 Message Date
Ryan Leckey
96b76dc737 update todo examples to 0.4 and use migrations
* update tests/x.py

 * add examples/x.py
2020-07-18 05:43:16 -07:00
Ryan Leckey
fc682fa991 fix: adjust pool usage in tests and examples 2020-07-12 04:42:48 -07:00
Ryan Leckey
f0e79979dd fix: remove XQueryAs imports (gone in 0.4) 2020-06-27 06:02:14 -07:00
rage311
a0d1106f90 Added quotes to listen/unlisten channel names to honor case sensitivity and be consistent with 'listen_all()' 2020-06-05 19:50:44 -07:00
Ryan Leckey
9d2a0141cb
feat: introduce IntoArguments, query_with, query_as_with, and query_scalar_with 2020-05-30 17:51:55 -07:00
Austin Bonander
6b248e0d5f get offline macros working with todos example 2020-05-30 16:02:37 -07:00
PumpkinSeed
19edb73ffc Add meaningful errors 2020-05-15 12:45:32 -07:00
Milan Zivkovic
a034df87c4 fix issue with project name 2020-04-30 21:16:45 -07:00
Milan Zivkovic
3edf84ae3d Todo API example using Actix-web and SQLx with PostgreSQL database 2020-04-30 21:16:45 -07:00
Samani G. Gikandi
841d9a7f45 Changes PKs in realworld postgres to SERIAL
`GENERATED` was added in Postgres 12 and we test as far back as 9
2020-04-17 12:42:22 -07:00
Samani G. Gikandi
9fb523d4e8 Runs rustfmt across realworld 2020-04-17 12:42:22 -07:00
Samani G. Gikandi
8138a26b61 Finishes realworld example implementation
* Adds tables for  storing articles, tags, favorites, and comments.
* Implements all remaining web APIs (articles, tags, profiles, etc)

* Refactors `Provide` traits into
* `ProvideAuthn` is used to store/retrieve user info
* `ProvideData` is used to retrieve application data
* ` Provide` traits are now implemented on Connections instead of Pools
* Introduces `Db` trait that encapsulates DB connections

* Cleans up endpoint functions
2020-04-17 12:42:22 -07:00
Samani G. Gikandi
7038dd8ab2 Refactors realworld example with multi DB support
**General**

* Moves `examples/postgres/realworld` to `examples/realworld`
* The app is now architected to support multiple DBs
* Adds feature flags for `sqlite` and `postgres` to allow user to choose
  which backend to use

    *NOTE* Currently it is not possible to compile with `postgres` and `sqlite`
      enabled as we are using the `query!` and `query_as!` macros and they
      seem to get unhappy.

* Adds CLI flags for picking the DB backend to use at runtime
* Adds schema file and implementation for SQLite for `/api/user` routes
* Adds stub routes and trait for articles and Articles entity

**Changes**

* We now use i32 instead of i64 as the user_id to get around some quirks
  w/ the SQLite driver.
* Reimplements existing route handlers w/ an error handling shim so we can use
  Try inside the biz logic
* *FIX* Adds a `user` key to the register user body to conform w/ realworld's
  API specs

APIs were functionally tested using realworld's API test script
  (https://github.com/gothinkster/realworld/tree/master/api#authentication)
2020-04-17 12:42:22 -07:00
Reid Swan
42ff560577 Adds new Github Action to build examples 2020-04-02 15:36:12 +02:00
Jon Pacheco
38e630d107 Add comment regarding booleans in MySQL 2020-03-31 20:35:34 +01:00
Jon Pacheco
89c9b059e6 Fix formatting in SQLite example 2020-03-31 20:35:34 +01:00
Jon Pacheco
8d454c48d0 Use != 0 instead of > 0 2020-03-31 20:35:34 +01:00
Jon Pacheco
f4e4836fa6 Clone TODOs example for MySQL 2020-03-31 20:35:34 +01:00
Jon Pacheco
79a5e5e1d5 Clone TODOs example for SQLite
Differences to Postgres version:
- Minor changes to schema
- Add TODO: "RETURNING" isn't supported, so retrieve ID separately
2020-03-31 20:35:34 +01:00
Jon Pacheco
501ed887e3 Restructure examples folder 2020-03-31 00:35:07 +01:00
Ryan Leckey
db66163c9e realworld: remove usge of &mut Pool as its no longer needed 2020-03-27 17:00:58 -07:00
Ryan Leckey
e99e80cf94 listen: merge PgListener and PgPoolListener; allow PgListener to be used as an Executor; allow channels to be adjusted at run-time 2020-03-16 18:35:37 -07:00
Ryan Leckey
dc8e36c707 listen: prefix example with sqlx-example- 2020-03-16 18:27:04 -07:00
Ryan Leckey
4419aea619 update postgres/listen.rs for internal changes 2020-03-15 02:17:14 -07:00
Anthony Dodd
75a76395c6 Rename new example to match current nomenclature. 2020-03-15 02:17:14 -07:00
Anthony Dodd
ae7e15cbe3 Added demo program to show use of LISTEN/NOTIFY. 2020-03-15 02:17:14 -07:00
Ryan Leckey
433aab1e5b postgres: use RawValue in Decode and implement row-returning simple queries 2020-03-11 01:44:06 -07:00
Ryan Leckey
a374c18a18 postgres: rewrite protocol in more iterative and lazy fashion 2020-03-11 01:43:17 -07:00
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
Ryan Leckey
bdfea1a3cb
Merge pull request #90 from xcthulhu/master
Making realworld-postgres example compile
2020-01-31 23:28:49 -08:00
Jon Pacheco
cc7ef143cf Make "done" attribute not null 2020-01-28 15:10:09 +00:00
Jon Pacheco
4f61390f15 Address comments 2020-01-28 08:30:30 +00:00
Jon Pacheco
eece922ac3 Add todos CLI example for postgres 2020-01-27 10:17:58 +00:00
Matthew Doty
1e5e1eceb4 Making realworld-postgres example compile 2020-01-26 19:43:39 -05:00
Ryan Leckey
c13c1cc817 Add a bit more notes to the example about transactions 2020-01-15 00:26:13 -08:00
Ryan Leckey
b1a27ddac2 Add a Transaction type to simplify dealing with Transactions 2020-01-15 00:22:01 -08:00
Ryan Leckey
95fac72abf Use crossbeam queues to achieve fairness in the pool 2020-01-11 03:26:48 -08:00
Ryan Leckey
132f7b2944 Add test_on_acquire option to the Pool 2020-01-11 01:01:21 -08:00
Austin Bonander
43f1164823 fix macro examples and tests 2020-01-03 19:02:31 -08:00
Ryan Leckey
2068f05482 Update dependencies 2019-12-28 04:02:52 -08:00
Ryan Leckey
3cb9ddb8c6 Apply auto ref fixes to example 2019-12-28 00:23:04 -08:00
Ryan Leckey
8626cf5ba8 Tweak macro to only accept literals 2019-12-27 23:11:23 -08:00
Ryan Leckey
61237b8503 Implement Register and GetCurrentUser for RealWorld 2019-12-27 22:47:39 -08:00
Ryan Leckey
a23bfb60eb Clean up the example a touch 2019-12-27 21:50:13 -08:00
Austin Bonander
7d745f98ea implement query_as!() et al, document query macros 2019-12-27 21:45:31 -08:00
Ryan Leckey
56a82346f2 Run cargo fmt 2019-12-27 20:44:03 -08:00
Ryan Leckey
d76b1357da Audit MySql and Postgres protocols 2019-12-27 17:31:01 -08:00
Ryan Leckey
871183d23b Minor fixes and run rustfmt 2019-12-03 00:22:02 -08:00
Ryan Leckey
9558ab1c50 Remove bytes usage and update dependencies 2019-12-02 23:26:44 -08:00
Ryan Leckey
2227303f20 Have Backend require Executor and de-duplicate some logic 2019-11-27 23:26:20 -08:00