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]);
|
info!("object[0]={:?}",parsed_object[0]);
|
||||||
|
|
||||||
let mut word_orm_obj:Vec<word_entity::Model>=vec![];
|
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)
|
word_entity::add_to_database(word_orm_obj, &db_info.conn)
|
||||||
.await
|
.await
|
||||||
.map_err(|e|{error!("add to database error");error!("{}",e);exit(1)})
|
.unwrap_or_else(|e: Box<dyn Error>|{error!("add to database error");error!("{}",e);exit(1)});
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use log::info;
|
use log::info;
|
||||||
use sea_orm::{ConnectOptions, ConnectionTrait, Database, DatabaseConnection};
|
use sea_orm::{ConnectOptions, ConnectionTrait, Database, DatabaseConnection};
|
||||||
use std::error::Error;
|
use std::{error::Error, time::Duration};
|
||||||
use sea_orm::Schema;
|
use sea_orm::Schema;
|
||||||
|
|
||||||
pub struct Starter {
|
pub struct Starter {
|
||||||
@ -8,7 +8,9 @@ pub struct Starter {
|
|||||||
}
|
}
|
||||||
impl Starter {
|
impl Starter {
|
||||||
pub async fn connect(db_url:&str) -> Result<Self, Box<dyn Error>> {
|
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?;
|
let conn_new: DatabaseConnection = Database::connect(opt).await?;
|
||||||
|
|
||||||
Ok(Starter{conn:conn_new})
|
Ok(Starter{conn:conn_new})
|
||||||
|
Loading…
Reference in New Issue
Block a user