DomnerTech-SqlClient
DomnerTech-SqlClient is for connect to SQL like MSSQL and PostgreSQL
📦 Unified SQL Repo
A lightweight async SQL repository abstraction for MSSQL (Tiberius) and PostgreSQL (tokio-postgres). It provides a unified API for executing queries, commands, and bulk inserts across different databases using feature flags.
✨ Features
- ✅ Unified API for MSSQL and PostgreSQL
- ✅ Async connection pooling (custom pool manager)
- ✅ Unified parameter binding (UnifiedToSql)
- ✅ Query execution with mapping support
- ✅ Bulk insert with safe parameterization
- ✅ Feature-flagged: compile only the driver you need
🚀 Installation
Add this crate to your Cargo.toml
:
[]
= { = "0.1", = ["mssql"] }
# or
= { = "0.1", = ["pgsql"] }
# or
= { = "0.1", = ["mssql, pgsql"] }
Available features:
mssql
→ Enables tiberius for SQL Server
pgsql
→ Enables tokio-postgres for PostgreSQL
âš¡ Usage
Initialize a pool
use DbManager;
async
Execute a query
use ;
use ;
async
Bulk insert
let entities: = vec!;
let affected = execute_bulk_insert.await?;
🔧 Development
- MSSQL support requires SQL Server running with TCP enabled.
- PostgreSQL support requires a
postgresql://
connection string. - Run tests with the appropriate feature flag:
📜 License
Licensed under either of:
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)