就先写到这了

This commit is contained in:
shenjack 2024-07-19 18:38:59 +08:00
parent 0f06eb8107
commit 556958a38c
Signed by: shenjack
GPG Key ID: 7B1134A979775551
5 changed files with 694 additions and 6 deletions

670
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -2,5 +2,6 @@
resolver = "2"
members = [
"sr_download",
"migration"
"migration",
"db_part"
]

13
db_part/Cargo.toml Normal file
View File

@ -0,0 +1,13 @@
[package]
name = "db_part"
version = "0.1.0"
edition = "2021"
[dependencies]
anyhow = { version = "1.0.86", features = ["backtrace"] }
migration = { path = "../migration" }
sea-orm = {version = "0.12.15", features = [
"sqlx-postgres",
"runtime-tokio-rustls"
]}
tokio = { version = "1.38.1", features = ["full"] }

12
db_part/src/lib.rs Normal file
View File

@ -0,0 +1,12 @@
use anyhow::Ok;
use sea_orm::{ConnectOptions, Database, DatabaseConnection};
pub async fn init_db() -> anyhow::Result<()> {
let mut opt =
ConnectOptions::new("postgres://srdown:srdown@localhost:5432/srdown?currentSchema=srdown");
opt.max_connections(10).sqlx_logging(true);
let db = Database::connect(opt).await?;
Ok(())
}

View File

@ -6,7 +6,7 @@ use sea_orm_migration::prelude::*;
pub struct Migration;
#[derive(DeriveIden)]
struct SaveTypeEnum;
pub struct SaveTypeEnum;
#[derive(DeriveIden, EnumIter)]
pub enum SaveTypeVariants {