update
This commit is contained in:
parent
3383dcaffa
commit
5a6b6fa0bc
@ -33,7 +33,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
}
|
||||
};
|
||||
|
||||
info!("parsed object Ok!");
|
||||
info!("parsed object Ok!Vec.size={}",parsed_object.len());
|
||||
info!("object[0]={:?}",parsed_object[0]);
|
||||
|
||||
let mut word_orm_obj:Vec<word_entity::Model>=vec![];
|
||||
@ -44,8 +44,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
word_entity::add_to_database(word_orm_obj, &db_info.conn)
|
||||
.await
|
||||
.map_err(|e|{error!("add to database error");error!("{}",e);exit(1)})
|
||||
.unwrap();
|
||||
.unwrap_or_else(|e: Box<dyn Error>|{error!("add to database error");error!("{}",e);exit(1)});
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
use log::info;
|
||||
use sea_orm::{ConnectOptions, ConnectionTrait, Database, DatabaseConnection};
|
||||
use std::error::Error;
|
||||
use std::{error::Error, time::Duration};
|
||||
use sea_orm::Schema;
|
||||
|
||||
pub struct Starter {
|
||||
@ -8,7 +8,9 @@ pub struct Starter {
|
||||
}
|
||||
impl Starter {
|
||||
pub async fn connect(db_url:&str) -> Result<Self, Box<dyn Error>> {
|
||||
let opt: ConnectOptions = ConnectOptions::new(db_url);
|
||||
let mut opt: ConnectOptions = ConnectOptions::new(db_url);
|
||||
opt.connect_timeout(Duration::from_secs(360));
|
||||
|
||||
let conn_new: DatabaseConnection = Database::connect(opt).await?;
|
||||
|
||||
Ok(Starter{conn:conn_new})
|
||||
|
Loading…
Reference in New Issue
Block a user