use sea_orm::{Condition, ConnectOptions, ConnectionTrait, Database, DatabaseConnection}; use std::error::Error; use sea_orm::Schema; pub struct Starter { pub db: DatabaseConnection, } impl Starter { pub async fn connect() -> Result> { let opt: ConnectOptions = ConnectOptions::new("sqlite://test.db?mode=rwc"); let db_new: DatabaseConnection = Database::connect(opt).await?; Ok(Starter{db:db_new}) } pub async fn create_table(&self) -> Result<(), Box> { let backend = self.db.get_database_backend(); let schema = Schema::new(backend); let table_create_statement = schema.create_table_from_entity(super::word_entity::Entity); let table_create_result = self.db.execute(backend.build(&table_create_statement)).await?; println!("{:?}",table_create_result); Ok(()) } }