I’m writing an json-api in rust with actix-web and mysql.
Is it possible to use prepared statements for table names?
Like in php with mysqli it is possible to use something like this:
SELECT * FROM ??
and bind the table name before execution.
Is something similar possible in Rust with mysql crate?
I’m using the mysql crate, but i’m willing to move to sqlx or something different, if it is neccessary.
I tried following code:
let stmt = conn.prep("SELECT value, lang FROM ??").expect("Failed to fetch"); let result: Vec<(String, String)> = conn.exec(stmt, (lang.as_str(),)).expect("Failed to fetch");
But its throwing Failed to fetch: MySqlError { ERROR 1064 (42000): 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 '??' at line 1 }
Also tried with only one ?