[odb-users] Web http client as database runtime
adnan at rihan.fr
Thu Sep 30 11:07:09 EDT 2021
Thanks for your suggestions Boris,
I'm having a hard time understanding what you mean by "present your
web API as an existing database API", maybe you're suggesting the same
thing I was thinking about (but I certainly wasn't clear enough).
I wasn't talking about a complete engine, but just reusing the ODB
database API (persist(), find(), etc…) and reimplement them as web
calls instead of database calls. I think you meant the same?
I also had another idea, I could write an abstract "repository" class,
then implement 2 subclasses, a DatabaseRepository using ODB and an
HttpRepository using QtNetwork. Almost the same as in my previous
paragraph, but writing it made me realize it would be the same + extra
work to abstract that. Instead, it would be smart to reuse ODB
Regards, Adnan RIHAN
Le jeu. 30 sept. 2021 à 16:33, Boris Kolpackov
<boris at codesynthesis.com> a écrit :
> Adnan RIHAN <adnan at rihan.fr> writes:
> > I'm writing a stock management app using Qt (currently, only a standalone
> > version using QtSql and Sqlite), and I would like to support a "network
> > mode". The easiest way I thought about would be to use an ORM like ODB and
> > write a database runtime for web calls (GET calls for SELECT, POST/PUT for
> > INSERT/UPDATE, DELETE for DELETE FROM, …).
> > How would it be feasible to write a different runtime for ODB, and do
> > you think it's a smart approach please?
> I think it will be quite difficult both in terms of the amount of work
> as well as in terms of trying to fit something like this into what ODB
> expects (which is a transactional SQL database with prepared statement
> support). Probably the easiest way would be to try to present your web
> API as one of the existing database APIs (e.g., SQLite) or, maybe even
> better, write a foreign table extension and use the existing database
> API as a proxy.
More information about the odb-users