-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
19 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,21 @@ | ||
use luna_orm::error::LunaOrmError; | ||
use luna_orm::preclude::*; | ||
use luna_orm::prelude::*; | ||
use luna_orm::LunaOrmResult; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), LunaOrmError> { | ||
println!("Hello, world!"); | ||
async fn main() -> LunaOrmResult<()> { | ||
let config = SqliteLocalConfig { | ||
work_dir: "./workspace".to_string(), | ||
db_file: "test.db".to_string(), | ||
}; | ||
|
||
// 2. create a DB instance. | ||
let mut db: DB<SqliteDatabase> = SqliteDatabase::build(config).await.unwrap().into(); | ||
|
||
// 3. optional: you may need to create the table for the first time. | ||
let result = db.execute_plain( | ||
"CREATE TABLE IF NOT EXISTS `user`(`id` INT PRIMARY KEY, `age` INT, `name` VARCHAR(64))", | ||
).await?; | ||
|
||
println!("result: {}", result.rows_affected()); | ||
Ok(()) | ||
} |