Skip to content

Instantly share code, notes, and snippets.

@EnigmaCurry
Last active February 5, 2023 22:35
Show Gist options
  • Save EnigmaCurry/487afa7603a9ef24d40f415b6aaa3324 to your computer and use it in GitHub Desktop.
Save EnigmaCurry/487afa7603a9ef24d40f415b6aaa3324 to your computer and use it in GitHub Desktop.
[ryan@maldek sqlx-playground]$ \
> export PGHOST=postgres.maldek.shln.rymcg.tech
export PGPORT=5432
export PGUSER=tweedle
export PGDATABASE=tweedle
export PGSSLMODE=verify-full
export PGSSLCERT=/home/ryan/git/vendor/enigmacurry/d.rymcg.tech/postgresql/postgres.maldek.shln.rymcg.tech_tweedle.crt
export PGSSLKEY=/home/ryan/git/vendor/enigmacurry/d.rymcg.tech/postgresql/postgres.maldek.shln.rymcg.tech_tweedle.key
export PGSSLROOTCERT=/home/ryan/git/vendor/enigmacurry/d.rymcg.tech/postgresql/postgres.maldek.shln.rymcg.tech_ca.crt
[ryan@maldek sqlx-playground]$ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.11s
Running `target/debug/sqlx-playground`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Tls(NotPkcs8)', src/main.rs:11:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
[ryan@maldek sqlx-playground]$ RUST_BACKTRACE=full cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.12s
Running `target/debug/sqlx-playground`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Tls(NotPkcs8)', src/main.rs:11:10
stack backtrace:
0: 0x556aa5d2afda - std::backtrace_rs::backtrace::libunwind::trace::h34aec3ef6cd8ad7e
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
1: 0x556aa5d2afda - std::backtrace_rs::backtrace::trace_unsynchronized::h8035d38698d0f7a8
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
2: 0x556aa5d2afda - std::sys_common::backtrace::_print_fmt::hff968f6695a1ba22
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/sys_common/backtrace.rs:65:5
3: 0x556aa5d2afda - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h7eea0efe77acf1ec
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/sys_common/backtrace.rs:44:22
4: 0x556aa5d4813e - core::fmt::write::hc553f17407eb0b48
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/fmt/mod.rs:1208:17
5: 0x556aa5d26d75 - std::io::Write::write_fmt::h62e5f01a089f48c0
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/io/mod.rs:1682:15
6: 0x556aa5d2ada5 - std::sys_common::backtrace::_print::h52d116aff3db4cd1
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/sys_common/backtrace.rs:47:5
7: 0x556aa5d2ada5 - std::sys_common::backtrace::print::h9e7d2f98fb7af075
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/sys_common/backtrace.rs:34:9
8: 0x556aa5d2c58f - std::panicking::default_hook::{{closure}}::hf74999dab2d0a95c
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:267:22
9: 0x556aa5d2c2cb - std::panicking::default_hook::hc11ca7d10c44c42f
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:286:9
10: 0x556aa5d2cc9c - std::panicking::rust_panic_with_hook::hdb4da1ae79c845a5
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:688:13
11: 0x556aa5d2ca39 - std::panicking::begin_panic_handler::{{closure}}::h02b5b35b126d5cf2
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:579:13
12: 0x556aa5d2b48c - std::sys_common::backtrace::__rust_end_short_backtrace::h6c6853376cf416d1
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/sys_common/backtrace.rs:137:18
13: 0x556aa5d2c742 - rust_begin_unwind
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:575:5
14: 0x556aa5999c93 - core::panicking::panic_fmt::hfd9e949092070b66
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/panicking.rs:64:14
15: 0x556aa599a063 - core::result::unwrap_failed::h4d34d8346233eb49
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/result.rs:1791:5
16: 0x556aa599b698 - core::result::Result<T,E>::unwrap::h1abf8e13c2b15267
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/result.rs:1113:23
17: 0x556aa599dbe0 - sqlx_playground::main::{{closure}}::h96ae28785d812b6a
at /home/ryan/t/sqlx-playground/src/main.rs:5:16
18: 0x556aa59a0d64 - tokio::runtime::park::CachedParkThread::block_on::{{closure}}::h2fef02ca35e5cf71
at /home/ryan/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.25.0/src/runtime/park.rs:283:63
19: 0x556aa59a0708 - tokio::runtime::coop::with_budget::h6f4469aabf99f5c2
at /home/ryan/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.25.0/src/runtime/coop.rs:102:5
20: 0x556aa59a0708 - tokio::runtime::coop::budget::hc62e15fae894ac1b
at /home/ryan/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.25.0/src/runtime/coop.rs:68:5
21: 0x556aa59a0708 - tokio::runtime::park::CachedParkThread::block_on::h16af2586f68a8734
at /home/ryan/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.25.0/src/runtime/park.rs:283:31
22: 0x556aa599e1a6 - tokio::runtime::context::BlockingRegionGuard::block_on::h5086bb9bac047032
at /home/ryan/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.25.0/src/runtime/context.rs:315:13
23: 0x556aa599e886 - tokio::runtime::scheduler::multi_thread::MultiThread::block_on::hcb40fc10f77dab6c
at /home/ryan/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.25.0/src/runtime/scheduler/multi_thread/mod.rs:66:9
24: 0x556aa599efed - tokio::runtime::runtime::Runtime::block_on::ha25df69b2fe63b55
at /home/ryan/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.25.0/src/runtime/runtime.rs:284:45
25: 0x556aa599e645 - sqlx_playground::main::h34e1739fb7d9b673
at /home/ryan/t/sqlx-playground/src/main.rs:18:5
26: 0x556aa599abfb - core::ops::function::FnOnce::call_once::hf8d33040d0c462e2
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/ops/function.rs:507:5
27: 0x556aa599ff7e - std::sys_common::backtrace::__rust_begin_short_backtrace::hdb83b4786df89082
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/sys_common/backtrace.rs:121:18
28: 0x556aa59a20a1 - std::rt::lang_start::{{closure}}::hd515910ad8fe23c6
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/rt.rs:166:18
29: 0x556aa5d22e5c - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h9ab31282e87f134a
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/core/src/ops/function.rs:606:13
30: 0x556aa5d22e5c - std::panicking::try::do_call::h42ddf5b01d0b4bc7
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:483:40
31: 0x556aa5d22e5c - std::panicking::try::hfb70320d7386c61a
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:447:19
32: 0x556aa5d22e5c - std::panic::catch_unwind::h978c9edbad2bb4d4
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panic.rs:137:14
33: 0x556aa5d22e5c - std::rt::lang_start_internal::{{closure}}::h04ede5bd2f26b553
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/rt.rs:148:48
34: 0x556aa5d22e5c - std::panicking::try::do_call::ha6b9da35a0885c93
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:483:40
35: 0x556aa5d22e5c - std::panicking::try::h3325520cab3a642e
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panicking.rs:447:19
36: 0x556aa5d22e5c - std::panic::catch_unwind::h160beec6f047175b
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/panic.rs:137:14
37: 0x556aa5d22e5c - std::rt::lang_start_internal::h79190e3a877a769d
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/rt.rs:148:20
38: 0x556aa59a207a - std::rt::lang_start::h0040f388de9e45bb
at /rustc/fc594f15669680fa70d255faec3ca3fb507c3405/library/std/src/rt.rs:165:17
39: 0x556aa599e6ee - main
40: 0x7fa03fd54290 - <unknown>
41: 0x7fa03fd5434a - __libc_start_main
42: 0x556aa599a245 - _start
43: 0x0 - <unknown>
use sqlx;
#[tokio::main]
async fn main() {
let pool = sqlx::postgres::PgPoolOptions::new()
.max_connections(5)
// Connect using the standard PostgreSQL environment variables:
// PGHOST PGUSER PGPASSWORD PGDATABASE
.connect("postgres://")
.await
.unwrap();
let row: (i64,) = sqlx::query_as("SELECT $1 + $2")
.bind(1)
.bind(46)
.fetch_one(&pool)
.await
.unwrap();
println!("answer: {}",row.0);
}
-----BEGIN CERTIFICATE-----
MIIDOzCCAiOgAwIBAgIRANcY0dOxEr+3bNjH0qaCp9IwDQYJKoZIhvcNAQELBQAw
FTETMBEGA1UEAxMKRXhhbXBsZSBDQTAgFw0yMzAyMDUxOTUxNDFaGA8yMTIzMDEx
MjE5NTE0MFowEjEQMA4GA1UEAxMHdHdlZWRsZTCCASIwDQYJKoZIhvcNAQEBBQAD
ggEPADCCAQoCggEBAOYf1u57tW+arF+B/gbgA5Su12AhZ+gyz3NmYNoe/wXwHXy3
sR3x6oJwsdqNQo8r379ZDDd8fdObwcmoAbH1+5e/D6RzZ9xgi/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MQUytxC2PJoaBxyv50bDc
JDMC3bHRD4fgymMazl5EIzcIlGS4DXnSdduQRLhYxLrGr1wZZqqgliBUzVPp1pqq
kxuVr08oQ/Sd1pF1hciQcEHZ6k5CSXWpMYEpu/YDuWaBZePoVTW1q9eTU3Fstzyl
zhRWDE0T2LZWFw0mWwRBvSUN5koSqKUk/6JP0NA8A/zcH6KsztS1HPuDV8m3Z3vZ
LVQzr5SLUNup8y5sGQ3XFbPA7Va6w3apfJlK1Ky76/8Y0be8MEEdKswBAk5rcxWa
Y+FZjIy+BZomPHeRUrGUTnNqvDS9zyy+HdVK6tvJgexi0VbFDHMJmxdL77HHww==
-----END CERTIFICATE-----
[package]
name = "sqlx-playground"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
sqlx = { git = "https://github.com/ThibsG/sqlx", branch = "postgres-native-tls-fixes", features = [ "runtime-tokio-native-tls" , "postgres" ] }
tokio = { version = "1", features = ["full"] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment