1#![cfg_attr(
18 any(sqlx_macros_unstable, procmacro2_semver_exempt),
19 feature(track_path)
20)]
21
22#[cfg(feature = "macros")]
23use crate::query::QueryDriver;
24
25pub type Error = Box<dyn std::error::Error>;
26
27pub type Result<T> = std::result::Result<T, Error>;
28
29mod common;
30mod database;
31
32#[cfg(feature = "derive")]
33pub mod derives;
34#[cfg(feature = "macros")]
35pub mod query;
36
37#[cfg(feature = "macros")]
38pub mod test_attr;
40
41#[cfg(feature = "migrate")]
42pub mod migrate;
43
44#[cfg(feature = "macros")]
45pub const FOSS_DRIVERS: &[QueryDriver] = &[
46 #[cfg(feature = "mysql")]
47 QueryDriver::new::<sqlx_mysql::MySql>(),
48 #[cfg(feature = "postgres")]
49 QueryDriver::new::<sqlx_postgres::Postgres>(),
50 #[cfg(feature = "_sqlite")]
51 QueryDriver::new::<sqlx_sqlite::Sqlite>(),
52];
53
54pub fn block_on<F>(f: F) -> F::Output
55where
56 F: std::future::Future,
57{
58 #[cfg(feature = "_rt-tokio")]
59 {
60 use once_cell::sync::Lazy;
61 use tokio::runtime::{self, Runtime};
62
63 static TOKIO_RT: Lazy<Runtime> = Lazy::new(|| {
66 runtime::Builder::new_current_thread()
67 .enable_all()
68 .build()
69 .expect("failed to start Tokio runtime")
70 });
71
72 TOKIO_RT.block_on(f)
73 }
74
75 #[cfg(all(feature = "_rt-async-std", not(feature = "tokio")))]
76 {
77 async_std::task::block_on(f)
78 }
79
80 #[cfg(not(any(feature = "_rt-async-std", feature = "tokio")))]
81 sqlx_core::rt::missing_rt(f)
82}