forked from blackbeam/mysql_async
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from second-state/chore/wasi_socket_5
Bump wasmedge_wasi_socket to 0.5
- Loading branch information
Showing
3 changed files
with
61 additions
and
13 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,39 @@ | ||
name: examples | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
logLevel: | ||
description: 'Log level' | ||
required: true | ||
default: 'info' | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Install WasmEdge | ||
run: curl -sSf https://raw.githubusercontent.com/WasmEdge/WasmEdge/master/utils/install.sh | bash -s | ||
- name: Install Rust | ||
run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | bash -s -- -y | ||
- name: Install Rust target | ||
run: cargo install cargo-wasi | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: setup mysql | ||
uses: shogo82148/actions-setup-mysql@v1 | ||
with: | ||
mysql-version: '8.0' | ||
user: 'test' | ||
password: 'password' | ||
- name: Create DataBase | ||
run: mysql -utest -h127.0.0.1 -ppassword -e 'CREATE DATABASE db_name' | ||
- name: Build & Run | ||
run: | | ||
cd examples/crud | ||
cargo wasi build | ||
~/.wasmedge/bin/wasmedge --env 'DATABASE_URL=mysql://test:[email protected]:3306/db_name' target/wasm32-wasi/debug/crud.wasm |
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,6 +1,4 @@ | ||
use mysql_async::{ | ||
prelude::*, Opts, OptsBuilder, Pool, PoolConstraints, PoolOpts, QueryResult, Result, | ||
}; | ||
use mysql_async::{prelude::*, Opts, OptsBuilder, Pool, PoolConstraints, PoolOpts, Result}; | ||
|
||
fn get_url() -> String { | ||
if let Ok(url) = std::env::var("DATABASE_URL") { | ||
|
@@ -14,7 +12,7 @@ fn get_url() -> String { | |
} | ||
url | ||
} else { | ||
"mysql://root:[email protected]:3306/mysql".into() | ||
"mysql://root:[email protected]:3306/test_db".into() | ||
} | ||
} | ||
|
||
|
@@ -29,7 +27,6 @@ struct Order { | |
shipping_address: String, | ||
} | ||
|
||
|
||
impl Order { | ||
fn new( | ||
order_id: i32, | ||
|
@@ -52,7 +49,6 @@ impl Order { | |
} | ||
} | ||
|
||
|
||
#[tokio::main(flavor = "current_thread")] | ||
async fn main() -> Result<()> { | ||
let opts = Opts::from_url(&*get_url()).unwrap(); | ||
|
@@ -79,7 +75,6 @@ async fn main() -> Result<()> { | |
r"DELETE FROM orders;".ignore(&mut conn).await?; | ||
} | ||
|
||
|
||
let orders = vec![ | ||
Order::new(1, 12, 2, 56.0, 15.0, 2.0, String::from("Mataderos 2312")), | ||
Order::new(2, 15, 3, 256.0, 30.0, 16.0, String::from("1234 NW Bobcat")), | ||
|
@@ -132,7 +127,7 @@ async fn main() -> Result<()> { | |
|
||
// delete some data | ||
let _ = conn | ||
.query_iter("DELETE FROM commerce WHERE OrderID=4;") | ||
.query_iter("DELETE FROM orders WHERE order_id=4;") | ||
.await?; | ||
// query data | ||
let loaded_orders = "SELECT * FROM orders" | ||
|
@@ -160,7 +155,6 @@ async fn main() -> Result<()> { | |
SET shipping_address = '8366 Elizabeth St.' | ||
WHERE order_id = 2;" | ||
.ignore(&mut conn) | ||
|
||
.await?; | ||
// query data | ||
let loaded_orders = "SELECT * FROM orders" | ||
|