In a project I use to learn Rust, I would like to have an utility to export SQlite3 tables into a series of SQL statements suitable for Postgres (and same for the other direction). I know about pg_loader, ETLAlchemy, etc, - but since the project right now has codegens in both C# entity framework and diesel, and needs to work transparently on both sqlite3 and postgresql backends, moving the data between the two databases with the above involves a lot of brittle massaging with awk and sed, so I decided to give a pure-rust approach a shot. Postgres->Sqlite3 worked nicely, but I am not finding my Sqlite3->postgres solution too elegant.
I could only get Row::get*(i) function calls to compile when using a constant for “i”, (thus the obvious solution of just iterating over N values and getting the value depending on type didn’t work), so the best I could come with is what I consider a sort of an abuse of macros:
Even though it works fine, the “1, 2, 3, 4, 5 …” sequence of parameters seems a bit ugly…
Is there a better way ? I know it is a bit of a special use case, so maybe I am using the microscope as a hammer