16 lines
379 B
Rust
16 lines
379 B
Rust
use sqlx::PgPool;
|
|
use sqlx::postgres::PgPoolOptions;
|
|
use tracing::info;
|
|
|
|
pub async fn init_database(database_url: &str) -> Result<PgPool, sqlx::Error> {
|
|
let pool = PgPoolOptions::new()
|
|
.max_connections(10)
|
|
.connect(database_url)
|
|
.await?;
|
|
|
|
// MIGRATOR.run(&pool).await?;
|
|
|
|
info!("数据库已连接,如有迁移请手动执行");
|
|
Ok(pool)
|
|
}
|