Expand description
Secra Database 库
提供数据库连接、连接池、Schema 和表管理功能
§示例
use secra_database::{DatabaseConfig, DatabaseService, ConnectionOptions};
let config = DatabaseConfig {
database_type: "postgres".to_string(),
host: "localhost".to_string(),
port: 5432,
username: "user".to_string(),
password: "password".to_string(),
database_name: "mydb".to_string(),
schema: "public".to_string(),
logging_level: "info".to_string(),
use_pgbouncer: false,
};
let db = DatabaseService::init(&config, None).await?;Re-exports§
pub use connection::DatabaseConfig;pub use connection::DatabaseError;pub use connection::DatabaseService;pub use connection::ConnectionOptions;pub use pool::ConnectionPoolService;pub use pool::PoolError;pub use pool::PoolStats;pub use schema::SchemaError;pub use schema::SchemaInfo;pub use schema::SchemaService;pub use table::TableError;pub use table::TableInfo;pub use table::TableColumnInfo;pub use table::TableService;
Modules§
- connection
- 数据库连接管理服务
- models
- 数据库模型模块
- pool
- 连接池管理服务
- schema
- Schema 管理服务
- table
- 数据库表管理服务