November 15, 2019
Sometimes the diesel abstraction is not enough if you want to execute more complex queries. This is totally possible, but the documentation is a bit brief on that topic, and the “SqlQuery bind” example shows MySQL syntax (which threw me off, since my postgres-query-writing-know-how is a bit rusty ATM).
I wanted to execute the following query:
insert into store_traffic_uploads (store_id, batch_id) select id as store_id, $1 from stores where id not in (select store_id from store_traffic_uploads) limit $2 ; The corresponding Rust Code then looks like this: