#![cfg_attr(
any(sqlx_macros_unstable, procmacro2_semver_exempt),
feature(track_path)
)]
#[cfg(feature = "macros")]
use crate::query::QueryDriver;
pub type Error = Box<dyn std::error::Error>;
pub type Result<T> = std::result::Result<T, Error>;
mod common;
mod database;
#[cfg(feature = "derive")]
pub mod derives;
#[cfg(feature = "macros")]
pub mod query;
#[cfg(feature = "macros")]
pub mod test_attr;
#[cfg(feature = "migrate")]
pub mod migrate;
#[cfg(feature = "macros")]
pub const FOSS_DRIVERS: &[QueryDriver] = &[
#[cfg(feature = "mysql")]
QueryDriver::new::<sqlx_mysql::MySql>(),
#[cfg(feature = "postgres")]
QueryDriver::new::<sqlx_postgres::Postgres>(),
#[cfg(feature = "_sqlite")]
QueryDriver::new::<sqlx_sqlite::Sqlite>(),
];
pub fn block_on<F>(f: F) -> F::Output
where
F: std::future::Future,
{
#[cfg(feature = "_rt-tokio")]
{
use once_cell::sync::Lazy;
use tokio::runtime::{self, Runtime};
static TOKIO_RT: Lazy<Runtime> = Lazy::new(|| {
runtime::Builder::new_current_thread()
.enable_all()
.build()
.expect("failed to start Tokio runtime")
});
TOKIO_RT.block_on(f)
}
#[cfg(all(feature = "_rt-async-std", not(feature = "tokio")))]
{
async_std::task::block_on(f)
}
#[cfg(not(any(feature = "_rt-async-std", feature = "tokio")))]
sqlx_core::rt::missing_rt(f)
}