Skip to main content

sz_orm_sqlx/
lib.rs

1//! SZ-ORM sqlx adapter
2//!
3//! Provides Connection and ConnectionFactory implementations for sz-orm-core,
4//! supporting MySQL, PostgreSQL, and SQLite.
5//!
6//! Does not use sqlx::Any; instead implements each backend separately to avoid type limitations and lifetime issues.
7//!
8//! # Examples
9//!
10//! ```no_run
11//! use sz_orm_core::{Pool, PoolConfigBuilder};
12//! use sz_orm_sqlx::{SqlitePoolHandle, SqlxSqliteConnectionFactory};
13//! use std::sync::Arc;
14//!
15//! # #[tokio::main]
16//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
17//! let pool_handle = SqlitePoolHandle::connect("sqlite::memory:").await?;
18//! let factory = Arc::new(SqlxSqliteConnectionFactory::new(Arc::new(pool_handle)));
19//! let config = PoolConfigBuilder::new().max_size(10).build()?;
20//! let pool = Pool::new(config, factory)?;
21//!
22//! let mut conn = pool.acquire().await?;
23//! let rows = conn.query("SELECT 1 as one").await?;
24//! assert_eq!(rows.len(), 1);
25//! # Ok(())
26//! # }
27//! ```
28
29mod any;
30pub mod any_driver;
31pub mod enhanced;
32mod error;
33#[cfg(feature = "dialect-saphana-driver")]
34pub mod saphana_adapter;
35pub mod unified_pool;
36
37pub use any::{
38    mysql_bulk_insert, pg_bulk_insert, sqlite_backup, MySqlPoolHandle, PgExtensions, PgPoolHandle,
39    SqlitePoolHandle, SqlxMySqlConnection, SqlxMySqlConnectionFactory, SqlxPgConnection,
40    SqlxPgConnectionFactory, SqlxSqliteConnection, SqlxSqliteConnectionFactory,
41};
42pub use any_driver::{AnyBackend, AnyConnection, AnyPool};
43pub use enhanced::{
44    CacheStats, EnhancedPoolConfig, EnhancedPoolConfigBuilder, PreparedStatementCache,
45    TransactionIsolation,
46};
47pub use error::map_sqlx_error;
48pub use unified_pool::UnifiedPool;
49
50pub use sz_orm_core;