Skip to content

Commit 7d62d9a

Browse files
authored
Update README.md
1 parent daf7f6c commit 7d62d9a

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

README.md

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,63 @@
4141

4242
SQLx is a modern SQL client built from the ground up for Rust, in Rust.
4343

44-
* **Truly Asynchronous**. Built from the ground-up using [async-std] using async streams for maximum concurrency.
44+
* **Truly Asynchronous**. Built from the ground-up using async/await for maximum concurrency.
4545

4646
* **Type-safe SQL** (if you want it) without DSLs. Use the `query!()` macro to check your SQL and bind parameters at
4747
compile time. (You can still use dynamic SQL queries if you like.)
4848

4949
* **Pure Rust**. The Postgres and MySQL/MariaDB drivers are written in pure Rust using **zero** unsafe code.
50+
51+
* **Runtime Agnostic**. Works on [async-std](https://crates.io/crates/async-std) or [tokio](https://crates.io/crates/tokio) with the `runtime-async-std` or `runtime-tokio` cargo feature flag.
52+
53+
## Install
54+
55+
**async-std**
56+
57+
```toml
58+
# Cargo.toml
59+
[dependencies]
60+
sqlx = "0.2"
61+
```
62+
63+
**tokio**
64+
65+
```toml
66+
# Cargo.toml
67+
[dependencies]
68+
sqlx = { version = "0.2", no-default-features = true, features = [ "runtime-tokio", "macros" ] }
69+
```
70+
71+
#### Cargo Feature Flags
72+
73+
* `runtime-async-std` (on by default): Use the `async-std` runtime.
74+
75+
* `runtime-tokio`: Use the `tokio` runtime. Mutually exclusive with the `runtime-async-std` feature.
76+
77+
* `postgres`: Add support for the Postgres database server.
78+
79+
* `mysql`: Add support for the MySQL (and MariaDB) database server.
80+
81+
* `uuid`: Add support for UUID (in Postgres).
82+
83+
* `chrono`: Add support for date and time types from `chrono`.
84+
85+
* `tls`: Add support for TLS connections.
5086

51-
[async-std]: https://github.com/async-rs/async-std
5287
## Examples
5388

89+
#### Connect
90+
91+
It is a very good idea to always create a connection pool at the beginning of your application
92+
and then share that.
93+
94+
```rust
95+
# Postgres
96+
let pool = sqlx::PgPool::new("postgres://localhost/database").await?;
97+
```
98+
99+
#### Dynamic
100+
54101
The `sqlx::query` function provides general-purpose prepared statement execution.
55102
The result is an implementation of the `Row` trait. Values can be efficiently accessed by index or name.
56103

@@ -63,6 +110,8 @@ let row = sqlx::query("SELECT is_active FROM users WHERE id = ?")
63110
let is_active: bool = row.get("is_active");
64111
```
65112

113+
#### Static
114+
66115
The `sqlx::query!` macro prepares the SQL query and interprets the result in order to constrain input types and
67116
infer output types. The result of `query!` is an anonymous struct (or named tuple).
68117

0 commit comments

Comments
 (0)