Browse Source

Testing the Any database of SQLx

master
Julio Biason 3 years ago
parent
commit
9b7db60af6
  1. 47
      sqlxany/Cargo.lock
  2. 2
      sqlxany/Cargo.toml
  3. 3
      sqlxany/src/entity.rs
  4. 7
      sqlxany/src/main.rs

47
sqlxany/Cargo.lock generated

@ -34,6 +34,17 @@ version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
[[package]]
name = "bigdecimal"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1e50562e37200edf7c6c43e54a08e64a5553bfb59d9c297d5572512aa517256"
dependencies = [
"num-bigint",
"num-integer",
"num-traits",
]
[[package]]
name = "bitflags"
version = "1.3.2"
@ -79,6 +90,18 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "chrono"
version = "0.4.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73"
dependencies = [
"libc",
"num-integer",
"num-traits",
"winapi",
]
[[package]]
name = "cpufeatures"
version = "0.2.1"
@ -499,6 +522,27 @@ dependencies = [
"winapi",
]
[[package]]
name = "num-bigint"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f6f7833f2cbf2360a6cfd58cd41a53aa7a90bd4c202f5b1c7dd2ed73c57b2c3"
dependencies = [
"autocfg",
"num-integer",
"num-traits",
]
[[package]]
name = "num-integer"
version = "0.1.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db"
dependencies = [
"autocfg",
"num-traits",
]
[[package]]
name = "num-traits"
version = "0.2.14"
@ -852,9 +896,11 @@ dependencies = [
"ahash",
"atoi",
"base64",
"bigdecimal",
"bitflags",
"byteorder",
"bytes",
"chrono",
"crc",
"crossbeam-queue",
"dirs",
@ -875,6 +921,7 @@ dependencies = [
"log",
"md-5",
"memchr",
"num-bigint",
"once_cell",
"paste",
"percent-encoding",

2
sqlxany/Cargo.toml

@ -6,5 +6,5 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
sqlx = { version = "0.5.11", features = ["runtime-tokio-rustls", "postgres", "sqlite", "any", "macros", "migrate"] }
sqlx = { version = "0.5.11", features = ["runtime-tokio-rustls", "postgres", "sqlite", "any", "macros", "migrate", "bigdecimal", "chrono"] }
tokio = { version = "1.17.0", features = ["rt", "rt-multi-thread", "macros", "time"] }

3
sqlxany/src/entity.rs

@ -11,7 +11,10 @@ VALUES
#[derive(sqlx::FromRow)]
pub struct Entity {
#[sqlx(rename = "chave")]
id: i64,
#[sqlx(rename = "descricao")]
description: String,
}

7
sqlxany/src/main.rs

@ -1,3 +1,5 @@
use std::sync::Arc;
use sqlx::{Any, Pool};
mod entity;
@ -5,9 +7,10 @@ mod entity;
#[tokio::main]
async fn main() {
let record = entity::Entity::new(1, "Something");
let pool =
let pool = Arc::new(
Pool::<Any>::connect(&std::env::var("DATABASE_URL").expect("I need DATABASE_URL set!"))
.await
.expect("Failed to connect to the database");
.expect("Failed to connect to the database"),
);
record.save(&pool).await.unwrap();
}

Loading…
Cancel
Save