sqlx_core_oldapi/odbc/mod.rs
1//! ODBC database driver (via `odbc-api`).
2//!
3//! ## Connection Strings
4//!
5//! When using the `Any` connection type, SQLx accepts standard ODBC connection strings:
6//!
7//! ```text
8//! // DSN-based connection
9//! DSN=MyDataSource;UID=myuser;PWD=mypassword
10//!
11//! // Driver-based connection
12//! Driver={ODBC Driver 17 for SQL Server};Server=localhost;Database=test
13//!
14//! // File DSN
15//! FILEDSN=/path/to/myfile.dsn
16//! ```
17//!
18//! The `odbc:` URL scheme prefix is optional but still supported for backward compatibility:
19//!
20//! ```text
21//! odbc:DSN=MyDataSource
22//! ```
23//!
24//! ## Buffer Configuration
25//!
26//! You can configure buffer settings for performance tuning:
27//!
28//! ```rust,no_run
29//! use std::str::FromStr;
30//! use sqlx_core_oldapi::odbc::{OdbcConnectOptions, OdbcBufferSettings};
31//!
32//! let mut opts = OdbcConnectOptions::from_str("DSN=MyDataSource")?;
33//!
34//! // Configure for high-throughput buffered mode
35//! opts.buffer_settings(OdbcBufferSettings {
36//! batch_size: 256, // Fetch 256 rows at once
37//! max_column_size: Some(2048), // Limit text columns to 2048 chars
38//! });
39//!
40//! // Configure for unbuffered mode (no truncation, row-by-row processing)
41//! opts.buffer_settings(OdbcBufferSettings {
42//! batch_size: 128, // batch_size ignored in unbuffered mode
43//! max_column_size: None, // Enable unbuffered mode
44//! });
45//!
46//! // Or configure individual settings
47//! opts.batch_size(512)
48//! .max_column_size(Some(1024));
49//!
50//! // Switch to unbuffered mode
51//! opts.max_column_size(None);
52//! # Ok::<(), sqlx::Error>(())
53//! ```
54
55use crate::executor::Executor;
56
57mod arguments;
58mod column;
59mod connection;
60mod database;
61mod error;
62mod options;
63mod query_result;
64mod row;
65pub mod statement;
66mod transaction;
67mod type_info;
68pub mod types;
69mod value;
70
71pub use arguments::{OdbcArgumentValue, OdbcArguments};
72pub use column::OdbcColumn;
73pub use connection::OdbcConnection;
74pub use database::Odbc;
75pub use options::{OdbcBufferSettings, OdbcConnectOptions};
76pub use query_result::OdbcQueryResult;
77pub use row::{OdbcBatch, OdbcRow};
78pub use statement::{OdbcStatement, OdbcStatementMetadata};
79pub use transaction::OdbcTransactionManager;
80pub use type_info::{DataTypeExt, OdbcTypeInfo};
81pub use value::{ColumnData, OdbcValue, OdbcValueRef, OdbcValueType, OdbcValueVec};
82
83/// An alias for [`Pool`][crate::pool::Pool], specialized for ODBC.
84pub type OdbcPool = crate::pool::Pool<Odbc>;
85
86/// An alias for [`PoolOptions`][crate::pool::PoolOptions], specialized for ODBC.
87pub type OdbcPoolOptions = crate::pool::PoolOptions<Odbc>;
88
89/// An alias for [`Executor<'_, Database = Odbc>`][Executor].
90pub trait OdbcExecutor<'c>: Executor<'c, Database = Odbc> {}
91impl<'c, T: Executor<'c, Database = Odbc>> OdbcExecutor<'c> for T {}
92
93// NOTE: required due to the lack of lazy normalization
94impl_into_arguments_for_arguments!(crate::odbc::OdbcArguments);
95impl_executor_for_pool_connection!(Odbc, OdbcConnection, OdbcRow);
96impl_executor_for_transaction!(Odbc, OdbcRow);
97impl_column_index_for_row!(OdbcRow);
98impl_column_index_for_statement!(OdbcStatement);
99impl_acquire!(Odbc, OdbcConnection);
100impl_into_maybe_pool!(Odbc, OdbcConnection);
101
102// custom Option<..> handling implemented in `arguments.rs`