axion-db
Core database interaction layer for the Axion framework.
Note: This crate is part of the Axion framework and is not typically intended for direct standalone use. It provides the foundational database connectivity, schema introspection, and type mapping capabilities that power Axion.
Overview
axion-db is responsible for:
- Database Configuration: Defining and managing connection parameters for various SQL databases.
- Connection Pooling: Utilizing
sqlx::AnyPoolfor efficient, asynchronous database connections. - Schema Introspection: Querying database metadata (schemas, tables, columns, views, functions, etc.) to understand the database structure.
- Type Mapping: Providing a basic mapping between SQL data types and corresponding Rust types for code generation and dynamic query handling within the Axion framework.
- Raw Query Execution: Offering a simple interface to execute raw SQL queries, primarily used by higher-level Axion components.
Features
- Async Native: Built on
sqlxandtokiofor fully asynchronous database operations. - Multi-Database Support (via
sqlx::Any):- PostgreSQL
- MySQL/MariaDB
- SQLite
- Connection Pooling: Leverages
sqlx's robust connection pooling. - Detailed Schema Introspection: Gathers information about tables, columns (types, nullability, PKs, FKs), views, functions, procedures, and enums.
- Configurable: Flexible
DbConfigfor various connection setups.
Usage
This crate is primarily consumed by other Axion components (axion-server and axion). Direct usage would typically involve setting up a DbConfig and then creating a DbClient to perform introspection or raw queries.
use *;
use Arc;
# async
For more comprehensive examples of how axion-db is used to power automatic API generation, please see the main Axion repository examples.