mirror of
https://github.com/launchbadge/sqlx.git
synced 2026-03-23 10:38:57 +00:00
refactor: split <Connection> into <Connect>, <Close>, <Acquire>, and <Connection>
This commit is contained in:
@@ -8,11 +8,11 @@ authors = [
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
actix-web = "3.3.2"
|
||||
#actix-web = "3.3.2"
|
||||
anyhow = "1.0.36"
|
||||
async-std = { version = "1.8.0", features = ["attributes"] }
|
||||
#async-std = { version = "1.8.0", features = ["attributes"] }
|
||||
tokio = { version = "1.0.1", features = ["rt", "rt-multi-thread", "macros"] }
|
||||
log = "0.4"
|
||||
env_logger = "0.8.2"
|
||||
#sqlx = { path = "../../sqlx", features = ["tokio", "mysql"] }
|
||||
sqlx = { path = "../../sqlx", features = ["blocking", "mysql"] }
|
||||
sqlx = { path = "../../sqlx", features = ["blocking", "tokio", "mysql"] }
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
// use sqlx::prelude::*;
|
||||
use sqlx::blocking::{prelude::*, Blocking};
|
||||
use sqlx::mysql::MySqlConnection;
|
||||
use sqlx::prelude::*;
|
||||
|
||||
// #[tokio::main]
|
||||
// async fn main() -> anyhow::Result<()> {
|
||||
// env_logger::try_init()?;
|
||||
//
|
||||
// let _conn = <MySqlConnection>::connect("mysql://root:password@localhost").await?;
|
||||
// // connect to the database
|
||||
// let mut conn = <MySqlConnection>::connect("mysql://root:password@localhost").await?;
|
||||
//
|
||||
// // ping, say HAI
|
||||
// conn.ping().await?;
|
||||
//
|
||||
// // , and now close the connection explicitly
|
||||
// conn.close().await?;
|
||||
//
|
||||
// Ok(())
|
||||
// }
|
||||
@@ -13,7 +21,10 @@ use sqlx::prelude::*;
|
||||
fn main() -> anyhow::Result<()> {
|
||||
env_logger::try_init()?;
|
||||
|
||||
let _conn = <MySqlConnection>::connect("mysql://root:password@localhost")?;
|
||||
let mut conn = <MySqlConnection<Blocking>>::connect("mysql://root:password@localhost")?;
|
||||
|
||||
conn.ping()?;
|
||||
conn.close()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user