SQL itself, as it turns out[1], has interesting work in this area: as originally envisioned, dynamic execution of SQL strings is the secondary option for using it, while the primary one is embedding SQL statements as statements in your source code, then passing it through a (DBMS-specific) preprocessor before feeding it to the host language implementation.
Unfortunately, it seems that byte strings as the ultimate ABI won out in this case.
Unfortunately, it seems that byte strings as the ultimate ABI won out in this case.
[1] https://news.ycombinator.com/item?id=35598251