2

In my sample program I'm trying to do the following:

use futures::StreamExt;
use sqlx::Connection;

#[tokio::main]
async fn main() {
    let mut conn = sqlx::MySqlConnection::connect("mysql://user:pass@localhost/db")
        .await
        .unwrap();

    let mut s = sqlx::query(concat!(
        "UPDATE foo SET bar=false WHERE id=34;",
        "UPDATE foo SET bar=true WHERE id=43;"
    ))
    .execute_many(&mut conn)
    .await;

    while let Some(k) = s.next().await {
        println!("{k:?}");
    }
}

But MySQL complains with You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UPDATE error. So the question is how one is supposed to pass multiple queries so that they are properly recognized. Needless to say I am aware that I can run each query individually but I'd like to stack them up all together for performance reasons (server network latency).

kyku
  • 5,892
  • 4
  • 43
  • 51
  • Turn on [query logging](https://mariadb.com/kb/en/general-query-log/) and find out how the DB actually receives the statements. – Oliver Weichhold Oct 14 '22 at 09:51
  • @OliverWeichhold, there are no entries for such multiple queries. Single queries show up as expected. – kyku Oct 24 '22 at 15:51

0 Answers0