burncloud-database-impl 0.1.0

Database implementations for multiple backends (PostgreSQL, MySQL, SQLite, MongoDB) for BurnCloud
Documentation

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:

[dependencies]
burncloud-database-impl = "0.1"

Feature Flags

By default, only PostgreSQL support is included. Enable other databases with feature flags:

[dependencies]
burncloud-database-impl = { version = "0.1", features = ["mysql", "sqlite"] }

Available features:

  • postgres (default) - PostgreSQL support via sqlx
  • mysql - MySQL support via mysql_async
  • sqlite - SQLite support via rusqlite
  • mongodb_support - MongoDB support via mongodb driver
  • all - Enable all database backends

Usage Examples

PostgreSQL

use burncloud_database_impl::PostgresConnection;
use burncloud_database_core::{DatabaseConnection, QueryContext};

let mut conn = PostgresConnection::new("postgresql://user:pass@localhost/db".to_string());
conn.connect().await?;

let context = QueryContext::default();
conn.ping().await?;

SQLite

use burncloud_database_impl::SQLiteConnection;

let mut conn = SQLiteConnection::new("./database.db".to_string());
conn.connect().await?;

MySQL

use burncloud_database_impl::MySQLConnection;

let mut conn = MySQLConnection::new("mysql://user:pass@localhost/db".to_string());
conn.connect().await?;

MongoDB

use burncloud_database_impl::MongoDBConnection;

let mut conn = MongoDBConnection::new(
    "mongodb://localhost:27017".to_string(),
    "my_database".to_string()
);
conn.connect().await?;

Query Parameters

All implementations support type-safe query parameters:

use burncloud_database_impl::{StringParam, I64Param, BoolParam};

let params: Vec<&dyn QueryParam> = vec![
    &StringParam("user_id".to_string()),
    &I64Param(42),
    &BoolParam(true),
];

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

at your option.