Skip to content

Commit dd22476

Browse files
committed
avoid incentivizing crate name aliasing
fixes #17
1 parent 1ba0370 commit dd22476

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ SQLx is compatible with the [`async-std`], [`tokio`] and [`actix`] runtimes; and
131131
# Cargo.toml
132132
[dependencies]
133133
# tokio + rustls
134-
sqlx = { package = "sqlx-oldapi", version = "0.6", features = [ "runtime-tokio-rustls" ] }
134+
sqlx-oldapi = { version = "0.6", features = [ "runtime-tokio-rustls" ] }
135135
# async-std + native-tls
136-
sqlx = { package = "sqlx-oldapi", version = "0.6", features = [ "runtime-async-std-native-tls" ] }
136+
sqlx-oldapi = { version = "0.6", features = [ "runtime-async-std-native-tls" ] }
137137
```
138138

139139
<small><small>The runtime and TLS backend not being separate feature sets to select is a workaround for a [Cargo issue](https://github.com/rust-lang/cargo/issues/3494).</small></small>
@@ -219,27 +219,27 @@ See the `examples/` folder for more in-depth usage.
219219
[dependencies]
220220
# PICK ONE:
221221
# Async-std:
222-
sqlx = { package = "sqlx-oldapi", version = "0.6", features = [ "runtime-async-std-native-tls", "postgres" ] }
222+
sqlx-oldapi = { version = "0.6", features = [ "runtime-async-std-native-tls", "postgres" ] }
223223
async-std = { version = "1", features = [ "attributes" ] }
224224

225225
# Tokio:
226-
sqlx = { package = "sqlx-oldapi", version = "0.6", features = [ "runtime-tokio-native-tls" , "postgres" ] }
226+
sqlx-oldapi = { version = "0.6", features = [ "runtime-tokio-native-tls" , "postgres" ] }
227227
tokio = { version = "1", features = ["full"] }
228228

229229
# Actix-web:
230-
sqlx = { package = "sqlx-oldapi", version = "0.6", features = [ "runtime-actix-native-tls" , "postgres" ] }
230+
sqlx-oldapi = { version = "0.6", features = [ "runtime-actix-native-tls" , "postgres" ] }
231231
actix-web = "4"
232232
```
233233

234234
```rust
235-
use sqlx::postgres::PgPoolOptions;
236-
// use sqlx::mysql::MySqlPoolOptions;
235+
use sqlx_oldapi::postgres::PgPoolOptions;
236+
// use sqlx_oldapi::mysql::MySqlPoolOptions;
237237
// etc.
238238

239239
#[async_std::main]
240240
// or #[tokio::main]
241241
// or #[actix_web::main]
242-
async fn main() -> Result<(), sqlx::Error> {
242+
async fn main() -> Result<(), sqlx_oldapi::Error> {
243243
// Create a connection pool
244244
// for MySQL, use MySqlPoolOptions::new()
245245
// for SQLite, use SqlitePoolOptions::new()
@@ -249,7 +249,7 @@ async fn main() -> Result<(), sqlx::Error> {
249249
.connect("postgres://postgres:password@localhost/test").await?;
250250

251251
// Make a simple query to return the given parameter (use a question mark `?` instead of `$1` for MySQL)
252-
let row: (i64,) = sqlx::query_as("SELECT $1")
252+
let row: (i64,) = sqlx_oldapi::query_as("SELECT $1")
253253
.bind(150_i64)
254254
.fetch_one(&pool).await?;
255255

@@ -264,12 +264,12 @@ async fn main() -> Result<(), sqlx::Error> {
264264
A single connection can be established using any of the database connection types and calling `connect()`.
265265

266266
```rust
267-
use sqlx::Connection;
267+
use sqlx_oldapi::Connection;
268268

269269
let conn = SqliteConnection::connect("sqlite::memory:").await?;
270270
```
271271

272-
Generally, you will want to instead create a connection pool (`sqlx::Pool`) in order for your application to
272+
Generally, you will want to instead create a connection pool (`sqlx_oldapi::Pool`) in order for your application to
273273
regulate how many server-side connections it's using.
274274

275275
```rust
@@ -289,21 +289,21 @@ and a `Query` or `QueryAs` struct is treated as a prepared query.
289289
```rust
290290
// low-level, Executor trait
291291
conn.execute("BEGIN").await?; // unprepared, simple query
292-
conn.execute(sqlx::query("DELETE FROM table")).await?; // prepared, cached query
292+
conn.execute(sqlx_oldapi::query("DELETE FROM table")).await?; // prepared, cached query
293293
```
294294

295295
We should prefer to use the high level, `query` interface whenever possible. To make this easier, there are finalizers
296296
on the type to avoid the need to wrap with an executor.
297297

298298
```rust
299-
sqlx::query("DELETE FROM table").execute(&mut conn).await?;
300-
sqlx::query("DELETE FROM table").execute(&pool).await?;
299+
sqlx_oldapi::query("DELETE FROM table").execute(&mut conn).await?;
300+
sqlx_oldapi::query("DELETE FROM table").execute(&pool).await?;
301301
```
302302

303303
The `execute` query finalizer returns the number of affected rows, if any, and drops all received results.
304304
In addition, there are `fetch`, `fetch_one`, `fetch_optional`, and `fetch_all` to receive results.
305305

306-
The `Query` type returned from `sqlx::query` will return `Row<'conn>` from the database. Column values can be accessed
306+
The `Query` type returned from `sqlx_oldapi::query` will return `Row<'conn>` from the database. Column values can be accessed
307307
by ordinal or by name with `row.get()`. As the `Row` retains an immutable borrow on the connection, only one
308308
`Row` may exist at a time.
309309

@@ -313,7 +313,7 @@ The `fetch` query finalizer returns a stream-like type that iterates through the
313313
// provides `try_next`
314314
use futures::TryStreamExt;
315315

316-
let mut rows = sqlx::query("SELECT * FROM users WHERE email = ?")
316+
let mut rows = sqlx_oldapi::query("SELECT * FROM users WHERE email = ?")
317317
.bind(email)
318318
.fetch(&mut conn);
319319

@@ -326,18 +326,18 @@ while let Some(row) = rows.try_next().await? {
326326
To assist with mapping the row into a domain type, there are two idioms that may be used:
327327

328328
```rust
329-
let mut stream = sqlx::query("SELECT * FROM users")
329+
let mut stream = sqlx_oldapi::query("SELECT * FROM users")
330330
.map(|row: PgRow| {
331331
// map the row into a user-defined domain type
332332
})
333333
.fetch(&mut conn);
334334
```
335335

336336
```rust
337-
#[derive(sqlx::FromRow)]
337+
#[derive(sqlx_oldapi::FromRow)]
338338
struct User { name: String, id: i64 }
339339

340-
let mut stream = sqlx::query_as::<_, User>("SELECT * FROM users WHERE email = ? OR name = ?")
340+
let mut stream = sqlx_oldapi::query_as::<_, User>("SELECT * FROM users WHERE email = ? OR name = ?")
341341
.bind(user_email)
342342
.bind(user_name)
343343
.fetch(&mut conn);
@@ -348,11 +348,11 @@ from the database.
348348

349349
### Compile-time verification
350350

351-
We can use the macro, `sqlx::query!` to achieve compile-time syntactic and semantic verification of the SQL, with
351+
We can use the macro, `sqlx_oldapi::query!` to achieve compile-time syntactic and semantic verification of the SQL, with
352352
an output to an anonymous record type where each SQL column is a Rust field (using raw identifiers where needed).
353353

354354
```rust
355-
let countries = sqlx::query!(
355+
let countries = sqlx_oldapi::query!(
356356
"
357357
SELECT country, COUNT(*) as count
358358
FROM users
@@ -399,7 +399,7 @@ mostly identical except that you can name the output type.
399399
// no traits are needed
400400
struct Country { country: String, count: i64 }
401401

402-
let countries = sqlx::query_as!(Country,
402+
let countries = sqlx_oldapi::query_as!(Country,
403403
"
404404
SELECT country, COUNT(*) as count
405405
FROM users

0 commit comments

Comments
 (0)