0

I need to insert multiple rows into a table, so I've got a query like INSERT INTO table (col1, col2) VALUES (?, ?) and arguments as list of pairs. Is there a way to execute it in SQLx without constructing a new string like INSERT ... VALUES ((?, ?), ..., (?, ?)) each time?

I found Query::execute_many, but I'm not sure if it's doing what, say, Python's executemany() from mysql adaptor is doing.

Yuri Astrakhan
  • 8,808
  • 6
  • 63
  • 97

1 Answers1

0

Actually MySql Python Connector's execute_many constructs VALUES ((?, ?), ..., (?, ?)) internally. If you want do that in sqlx, QueryBuilder::push_values can construct SQL VALUES strings for you.

Peng Guanwen
  • 547
  • 3
  • 9