use secra_database::{DatabaseConfig, DatabaseService, ConnectionOptions};
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = DatabaseConfig {
database_type: "postgres".to_string(),
host: "localhost".to_string(),
port: 5432,
username: "postgres".to_string(),
password: "password".to_string(),
database_name: "mydb".to_string(),
schema: "public".to_string(),
logging_level: "info".to_string(),
use_pgbouncer: false,
};
let options = ConnectionOptions {
max_connections: 100, min_connections: 10, connect_timeout: 10, acquire_timeout: 10, idle_timeout: 600, max_lifetime: 1800, sqlx_logging: true, };
println!("使用自定义连接选项创建连接...");
let db = DatabaseService::init(&config, Some(options)).await?;
println!("✓ 连接创建成功");
DatabaseService::test_connection(&db).await?;
println!("✓ 连接测试通过");
Ok(())
}