Closed fxfactorial closed 4 years ago
I'd say the answer is "most of it": if you leave Sqlexpr_sqlite_lwt aside, Sqlexpr_sqlite would need a ~ >90% rewrite (keeping only part of the directive machinery). As for the PostgreSQL backend, there are two options: using PG'OCaml's (without making use of its syntax), or postgresql-ocaml. The latter is written in blocking style though, so the former is a better pick (it's already functorized over the concurrency monad). The conversion could be more or less mechanical depending on the resemblance between Sqlite3's ang PG'OCaml's APIs.
It looks like quite a lot of work to get rid of PG'OCaml's camlp4 (I guess that would be the only reason not to use PG'OCaml directly). Wouldn't it be better to address it the other way around, by porting PG'OCaml's syntax to ppx? Or is there some value in using a single API for both Sqlite3 and PostgreSQL at a time (keeping in mind that the SQL itself is left as-is, so switching DBs would not be as easy as doing s/Sqlexpr_sqlite/Sqlexpr_postgresql/g)?
Porting PG'OCaml's syntax extension to PPX is on my TODO list, but it's a low priority task right now because Camlp4 still works, and I don't have all that much free time to dedicate to it. However, I'm also a Sqlexpr user, and I definitely intend for PG'OCaml's PPX syntax to borrow many of Sqlexpr's conventions...
Note that meanwhile there's a third option, PGX, which is essentially a simplified (and less opinionated) version of PG'OCaml:
how much of the codebase would have to be changed to incorporate postgresql?