burncloud-database-impl
Database implementations for multiple backends (PostgreSQL, MySQL, SQLite, MongoDB) for the BurnCloud AI management system.
Overview
burncloud-database-impl
provides concrete implementations of the traits defined in burncloud-database-core
for multiple popular database backends. This allows you to use the same high-level API regardless of which database you choose.
Supported Databases
- PostgreSQL (default) - Full-featured with advanced JSON support
- MySQL - Popular relational database
- SQLite - Lightweight embedded database
- MongoDB - Document-oriented NoSQL database
Features
- Multi-database support: Choose the right database for your needs
- Feature flags: Only compile the database drivers you need
- Async support: All implementations are fully async
- Connection pooling: Built-in connection pool management
- Error handling: Unified error handling across all backends
- Type safety: Strong typing with compile-time guarantees
Installation
Add this to your Cargo.toml
:
[]
= "0.1"
Feature Flags
By default, only PostgreSQL support is included. Enable other databases with feature flags:
[]
= { = "0.1", = ["mysql", "sqlite"] }
Available features:
postgres
(default) - PostgreSQL support via sqlxmysql
- MySQL support via mysql_asyncsqlite
- SQLite support via rusqlitemongodb_support
- MongoDB support via mongodb driverall
- Enable all database backends
Usage Examples
PostgreSQL
use PostgresConnection;
use ;
let mut conn = new;
conn.connect.await?;
let context = default;
conn.ping.await?;
SQLite
use SQLiteConnection;
let mut conn = new;
conn.connect.await?;
MySQL
use MySQLConnection;
let mut conn = new;
conn.connect.await?;
MongoDB
use MongoDBConnection;
let mut conn = new;
conn.connect.await?;
Query Parameters
All implementations support type-safe query parameters:
use ;
let params: = vec!;
Performance Considerations
- PostgreSQL: Best for complex queries and JSON operations
- MySQL: Good general-purpose choice with wide ecosystem support
- SQLite: Perfect for embedded applications and development
- MongoDB: Excellent for document-oriented data and flexible schemas
Architecture
Each database implementation provides:
- Connection management with automatic reconnection
- Query execution with parameter binding
- Transaction support (where applicable)
- Error handling with database-specific error mapping
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.