add mysql
This commit is contained in:
parent
4880070c64
commit
f25787db02
2605
Cargo.lock
generated
2605
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -4,3 +4,5 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
mysql = "25.0.1"
|
||||
actix-web = "4"
|
||||
|
||||
25
src/main.rs
25
src/main.rs
@ -1,6 +1,21 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
let n = 15;
|
||||
println!("n: {}", n);
|
||||
println!("n:{0}, n:{0}", n);
|
||||
use mysql::*;
|
||||
use mysql::prelude::*;
|
||||
fn main() -> Result<()> {
|
||||
// 连接mysql
|
||||
let url = "mysql://root:0andrx@122.152.201.90:9912/test_server";
|
||||
let pool = Pool::new(url)?;
|
||||
let mut conn = pool.get_conn()?;
|
||||
|
||||
// 执行查询
|
||||
conn.query_drop(
|
||||
r"CREATE TABLE IF NOT EXISTS users (
|
||||
id INT PRIMARY KEY AUTO_INCREMENT,
|
||||
name TEXT NOT NULL,
|
||||
age INT NOT NULL
|
||||
)"
|
||||
)?;
|
||||
|
||||
println!("Created users table");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user