In many cases preparing the statement would be preferable, of course. But sometimes that can bring more harm than good.
See this question and the partial solution I've posted. In a nutshell, sometimes we need to create a big query with a mixture of static and dynamic parameters. The static parameters will obviously lead to different query strings each time, so preparing that big statement will be pointless as it will practically only be called once.
I am using the mysql crate and when I try to call an INSERT
with more than 64K dynamic parameters, I get this error:
MySqlError { ERROR 1390 (HY000): Prepared statement contains too many placeholders }
I can do that easily with some other languages. For instance, with Python's mysql-connector-python
lib I have no problem passing a lot more than 64K dynamic parameters.
Does Rust's MySQL crate have a way to simply run a query without the overhead and limitations of preparing the statement?