We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am running this example wrong.
https://docs.rs/mysql_async/0.21.0-alpha.2/mysql_async/
use mysql_async::prelude::*; #[derive(Debug, PartialEq, Eq, Clone)] struct Payment { customer_id: i32, amount: i32, account_name: Option<String>, } #[tokio::main] async fn main() -> Result<(), mysql_async::error::Error> { let payments = vec![ Payment { customer_id: 1, amount: 2, account_name: None }, Payment { customer_id: 3, amount: 4, account_name: Some("foo".into()) }, Payment { customer_id: 5, amount: 6, account_name: None }, Payment { customer_id: 7, amount: 8, account_name: None }, Payment { customer_id: 9, amount: 10, account_name: Some("bar".into()) }, ]; let payments_clone = payments.clone(); let database_url = "mysql://[email protected]:3306/test_rust"; let pool = mysql_async::Pool::new(database_url); let conn = pool.get_conn().await?; // Create temporary table let conn = conn.drop_query( r"CREATE TEMPORARY TABLE payment ( customer_id int not null, amount int not null, account_name text )" ).await?; // Save payments let params = payments_clone.into_iter().map(|payment| { params! { "customer_id" => payment.customer_id, "amount" => payment.amount, "account_name" => payment.account_name.clone(), } }); let conn = conn.batch_exec(r"INSERT INTO payment (customer_id, amount, account_name) VALUES (:customer_id, :amount, :account_name)", params).await?; // Load payments from database. let result = conn.prep_exec("SELECT customer_id, amount, account_name FROM payment", ()).await?; // Collect payments let (_ /* conn */, loaded_payments) = result.map_and_drop(|row| { let (customer_id, amount, account_name) = mysql_async::from_row(row); Payment { customer_id: customer_id, amount: amount, account_name: account_name, } }).await?; // The destructor of a connection will return it to the pool, // but pool should be disconnected explicitly because it's // an asynchronous procedure. pool.disconnect().await?; assert_eq!(loaded_payments, payments); // the async fn returns Result, so Ok(()) }
mysql server 8.0.18
macos 10.15
The text was updated successfully, but these errors were encountered:
9cd2a6d
Hi! Thanks for report.
Should be fixed in 9cd2a6d and will be published in next release. Please set non-empty password until then.
Sorry, something went wrong.
OK, thanks.
No branches or pull requests
I am running this example wrong.
https://docs.rs/mysql_async/0.21.0-alpha.2/mysql_async/
mysql server 8.0.18
macos 10.15
The text was updated successfully, but these errors were encountered: