Re:Zig now has built-in HTTP server and client in std
by chatmasta on Thursday May 18, 2023 @07:37PM
(#35995849)
Parts of the library are interchangeable, but inevitably much of it is not. A Postgres and SQLite client might be able to share some query parsing logic between the two databases, but the wire protocol (or lack thereof for SQLite) is not the same, nor is the exact sub/super-set of the SQL standard implemented by each. Basically the only code you could reliably share is an AST parser for the most common subset of the SQL standard that's implemented by both.
[ Parent
| on HN ]
Re:Zig now has built-in HTTP server and client in std
by riceart on Thursday May 18, 2023 @07:41PM
(#35995891)
Database client libraries typically don’t parse SQL.
Re:Zig now has built-in HTTP server and client in std
by chatmasta on Thursday May 18, 2023 @07:44PM
(#35995923)
Yeah, that's true, so that's one less feature they'd be able to share. Unless you're creating an ORM, there's not much left aside from connecting to the database (different for all of them), sending packets (different for all of them), and maybe parameterizing queries. So basically you can make a query builder. Then of course you can have "drivers" for each database, but I'd consider that philosophically different from using the same library "without switching code" (IMO separate drivers implies "switching code" since each driver needs to be maintained separately and depends on a different upstream dependency).