From alcatania at gmail.com Thu Sep 2 11:29:34 2021 From: alcatania at gmail.com (Alessandro Catania) Date: Fri Sep 3 00:12:11 2021 Subject: [odb-users] undefined reference link error when use odm.dll Message-ID: I work on c++ code that use orm 2.3.0 on windows an gcc compiler. Orm code is generated by odb and is a library (that I call orm.dll) and contains polymorphism, in particular some destructors are defined pure virtual in base class. Empty destructors are implemented in Cxx source. Symbols are exported in my orm library as explained in manual in "16.2.2 Dynamic Loading of Database Support Code" This library compile correctly, but when I use it in another part of code linker give error undefined reference for destructors of base classes (defined as virtual). Could be that destructors symbols of base classes are not exported? But orm should export all class and then also destructors. Is there a working example that put together polymorphism https://git.codesynthesis.com/cgit/odb/odb-examples/tree/inheritance/polymorphism, library and use of library? Thanks and best regards, Ale From boris at codesynthesis.com Fri Sep 3 08:58:24 2021 From: boris at codesynthesis.com (Boris Kolpackov) Date: Fri Sep 3 08:56:56 2021 Subject: [odb-users] undefined reference link error when use odm.dll In-Reply-To: References: Message-ID: Alessandro Catania writes: > I work on c++ code that use orm 2.3.0 on windows an gcc compiler. Very old version, you should consider upgrading. > Orm code is generated by odb and is a library (that I call orm.dll) and > contains polymorphism, in particular some destructors are defined pure > virtual in base class. Empty destructors are implemented in Cxx source. > Symbols are exported in my orm library as explained in manual in "16.2.2 > Dynamic Loading of Database Support Code" > > This library compile correctly, but when I use it in another part of code > linker give error undefined reference for destructors of base classes > (defined as virtual). Are these the pure virtual or the empty from your description above? > Could be that destructors symbols of base classes are not exported? > But orm should export all class and then also destructors. This is most likely an idiosyncrasy of Windows DLL exporting semantics. If these are the pure virtual destructors we are talking about, make sure their classes have some non-inline function definition to "anchor" the vtable (and if there aren't any, try to turn the pure virtual destructor into just virtual with an non-inline definition). From alcatania at gmail.com Fri Sep 3 12:43:44 2021 From: alcatania at gmail.com (Alessandro Catania) Date: Mon Sep 6 03:19:20 2021 Subject: [odb-users] undefined reference link error when use odm.dll In-Reply-To: References: Message-ID: Hi Boris, Code is complex and made by several hands . > Are these the pure virtual or the empty from your description above? in file .hxx destructor is defined pure virtual class BaseClass { .... virtual ~BaseClass() =0 .... } // baseclass extends BaseClass DerivedClass:: public BaseClass { ... in file baseclass.cpp BaseClass destructor is implemented as: BaseClass::~BaseClass(){}; I found in code that use orm.dll a strange use like this: typedef odb::query queryD; typedef odb::result resultD; resultD res (db->query (queryD::id="blabla")); for (resultD::iterator i(res.begin()); i!=res.end(); ++i) { DerivedClass p; // this cause undefined reference BaseClass::~BaseClass() error i.load(p); // why don't use iterator i directly instead of load in p and use p?? Il giorno ven 3 set 2021 alle ore 14:58 Boris Kolpackov < boris@codesynthesis.com> ha scritto: > Alessandro Catania writes: > > > I work on c++ code that use orm 2.3.0 on windows an gcc compiler. > > Very old version, you should consider upgrading. > > > > Orm code is generated by odb and is a library (that I call orm.dll) and > > contains polymorphism, in particular some destructors are defined pure > > virtual in base class. Empty destructors are implemented in Cxx source. > > Symbols are exported in my orm library as explained in manual in "16.2.2 > > Dynamic Loading of Database Support Code" > > > > This library compile correctly, but when I use it in another part of code > > linker give error undefined reference for destructors of base classes > > (defined as virtual). > > Are these the pure virtual or the empty from your description above? > > > > Could be that destructors symbols of base classes are not exported? > > But orm should export all class and then also destructors. > > This is most likely an idiosyncrasy of Windows DLL exporting semantics. > If these are the pure virtual destructors we are talking about, make > sure their classes have some non-inline function definition to "anchor" > the vtable (and if there aren't any, try to turn the pure virtual > destructor into just virtual with an non-inline definition). > From boris at codesynthesis.com Mon Sep 6 09:39:09 2021 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Sep 6 09:37:39 2021 Subject: [odb-users] undefined reference link error when use odm.dll In-Reply-To: References: Message-ID: Alessandro Catania writes: > in file .hxx destructor is defined pure virtual > class BaseClass { > .... > virtual ~BaseClass() =0 > .... > } > > // baseclass extends BaseClass > DerivedClass:: public BaseClass { > ... > > in file baseclass.cpp BaseClass destructor is implemented as: > BaseClass::~BaseClass(){}; Is BaseClass exported? I.e., do you in reality have something like: class SOME_EXPORT_MACRO BaseClass { ... }; From alcatania at gmail.com Tue Sep 7 02:49:26 2021 From: alcatania at gmail.com (Alessandro Catania) Date: Tue Sep 7 09:56:41 2021 Subject: [odb-users] undefined reference link error when use odm.dll In-Reply-To: References: Message-ID: Yes, resolved with exoprt of base class. Thakss Il giorno lun 6 set 2021 alle ore 15:39 Boris Kolpackov < boris@codesynthesis.com> ha scritto: > Alessandro Catania writes: > > > in file .hxx destructor is defined pure virtual > > class BaseClass { > > .... > > virtual ~BaseClass() =0 > > .... > > } > > > > // baseclass extends BaseClass > > DerivedClass:: public BaseClass { > > ... > > > > in file baseclass.cpp BaseClass destructor is implemented as: > > BaseClass::~BaseClass(){}; > > Is BaseClass exported? I.e., do you in reality have something like: > > class SOME_EXPORT_MACRO BaseClass { > ... > }; > From scott.eddowes at hds.leica-geosystems.com Tue Sep 14 12:57:07 2021 From: scott.eddowes at hds.leica-geosystems.com (EDDOWES Scott) Date: Tue Sep 14 12:55:40 2021 Subject: [odb-users] Compile Error with Lazy Pointers Message-ID: I am having trouble getting lazy pointers to compile using ODB 2.4.0. I am setting the default pointer type to std::shared_ptr for my object classes (though possibly not correctly?). Please let me know what I can do to resolve this problem. Thanks! Example code: #include #include #pragma db object pointer(std::shared_ptr) class foo { public: foo(int value = 0) : mValue(value) {} ~foo() {} #pragma db id int mId; int mValue; }; #pragma db object pointer(std::shared_ptr) class bar { public: bar() {} ~bar() {} void SetFoo(std::shared_ptr& rpFoo) { mpFoo = rpFoo; } bool GetFooVal(int& rValue) { mpFoo.load(); if (mpFoo == nullptr) { return false; } rValue = mpFoo->mValue; return true; } #pragma db id int mId; odb::lazy_shared_ptr mpFoo; }; When I compile this in Visual Studio 2017, I get the following errors: 1>------ Build started: Project: LazyPointerExample, Configuration: Debug x64 ------ 1>Generating OdbGen/foobar-odb.cxx, OdbGen/foobar-odb.hxx, OdbGen/foobar-odb.ixx 1>In file included from Q:/BuildSdk/ODB/2.4.0/include/odb/lazy-ptr.hxx:668:0, 1> from D:/Labs/ODB/lazy_pointer_hell/src/foobar.hxx:2: 1>Q:/BuildSdk/ODB/2.4.0/include/odb/lazy-ptr.ixx: In instantiation of 'std::shared_ptr<_Tp1> odb::lazy_shared_ptr::load() const [with T = foo]': 1>D:/Labs/ODB/lazy_pointer_hell/src/foobar.hxx:30:16: required from here 1>Q:/BuildSdk/ODB/2.4.0/include/odb/lazy-ptr.ixx(1153,10): error G199EB5A7: no match for 'operator=' (operand types are 'std::shared_ptr' and 'odb::object_traits::pointer_type {aka foo*}') 1> p_ = i_.template load (true); // Reset id. 1> ^ 1>Q:/BuildSdk/ODB/2.4.0/include/odb/lazy-ptr.ixx:1153:10: note: candidates are: 1>In file included from q:\buildsdk\odb\2.4.0\odb-2.4.0-i686-windows\mingw\include\c++\4.9.3\memory:82:0, 1> from Q:/BuildSdk/ODB/2.4.0/include/odb/lazy-ptr.hxx:10, 1> from D:/Labs/ODB/lazy_pointer_hell/src/foobar.hxx:2: 1>q:\buildsdk\odb\2.4.0\odb-2.4.0-i686-windows\mingw\include\c++\4.9.3\bits\shared_ptr.h:93:11: note: std::shared_ptr<_Tp>& std::shared_ptr<_Tp>::operator=(const std::shared_ptr<_Tp>&) [with _Tp = foo] 1> class shared_ptr : public __shared_ptr<_Tp> 1> ^ 1>q:\buildsdk\odb\2.4.0\odb-2.4.0-i686-windows\mingw\include\c++\4.9.3\bits\shared_ptr.h:93:11: note: no known conversion for argument 1 from 'odb::object_traits::pointer_type {aka foo*}' to 'const std::shared_ptr&' 1>q:\buildsdk\odb\2.4.0\odb-2.4.0-i686-windows\mingw\include\c++\4.9.3\bits\shared_ptr.h:272:2: note: template std::shared_ptr<_Tp>& std::shared_ptr<_Tp>::operator=(const std::shared_ptr<_Tp1>&) [with _Tp1 = _Tp1; _Tp = foo] 1> operator=(const shared_ptr<_Tp1>& __r) noexcept 1> ^ 1>q:\buildsdk\odb\2.4.0\odb-2.4.0-i686-windows\mingw\include\c++\4.9.3\bits\shared_ptr.h:272:2: note: template argument deduction/substitution failed: 1>In file included from Q:/BuildSdk/ODB/2.4.0/include/odb/lazy-ptr.hxx:668:0, 1> from D:/Labs/ODB/lazy_pointer_hell/src/foobar.hxx:2: 1>Q:/BuildSdk/ODB/2.4.0/include/odb/lazy-ptr.ixx:1153:10: note: mismatched types 'const std::shared_ptr<_Tp1>' and 'odb::object_traits::pointer_type {aka foo*}' 1> p_ = i_.template load (true); // Reset id. 1> ^ 1>In file included from q:\buildsdk\odb\2.4.0\odb-2.4.0-i686-windows\mingw\include\c++\4.9.3\memory:82:0, 1> from Q:/BuildSdk/ODB/2.4.0/include/odb/lazy-ptr.hxx:10, 1> from D:/Labs/ODB/lazy_pointer_hell/src/foobar.hxx:2: 1>q:\buildsdk\odb\2.4.0\odb-2.4.0-i686-windows\mingw\include\c++\4.9.3\bits\shared_ptr.h:281:2: note: template std::shared_ptr<_Tp>& std::shared_ptr<_Tp>::operator=(std::auto_ptr<_Up>&&) [with _Tp1 = _Tp1; _Tp = foo] 1> operator=(std::auto_ptr<_Tp1>&& __r) 1> ^ 1>q:\buildsdk\odb\2.4.0\odb-2.4.0-i686-windows\mingw\include\c++\4.9.3\bits\shared_ptr.h:281:2: note: template argument deduction/substitution failed: 1>In file included from Q:/BuildSdk/ODB/2.4.0/include/odb/lazy-ptr.hxx:668:0, 1> from D:/Labs/ODB/lazy_pointer_hell/src/foobar.hxx:2: 1>Q:/BuildSdk/ODB/2.4.0/include/odb/lazy-ptr.ixx:1153:10: note: mismatched types 'std::auto_ptr' and 'odb::object_traits::pointer_type {aka foo*}' 1> p_ = i_.template load (true); // Reset id. 1> ^ 1>In file included from q:\buildsdk\odb\2.4.0\odb-2.4.0-i686-windows\mingw\include\c++\4.9.3\memory:82:0, 1> from Q:/BuildSdk/ODB/2.4.0/include/odb/lazy-ptr.hxx:10, 1> from D:/Labs/ODB/lazy_pointer_hell/src/foobar.hxx:2: 1>q:\buildsdk\odb\2.4.0\odb-2.4.0-i686-windows\mingw\include\c++\4.9.3\bits\shared_ptr.h:289:7: note: std::shared_ptr<_Tp>& std::shared_ptr<_Tp>::operator=(std::shared_ptr<_Tp>&&) [with _Tp = foo] 1> operator=(shared_ptr&& __r) noexcept 1> ^ 1>q:\buildsdk\odb\2.4.0\odb-2.4.0-i686-windows\mingw\include\c++\4.9.3\bits\shared_ptr.h:289:7: note: no known conversion for argument 1 from 'odb::object_traits::pointer_type {aka foo*}' to 'std::shared_ptr&&' 1>q:\buildsdk\odb\2.4.0\odb-2.4.0-i686-windows\mingw\include\c++\4.9.3\bits\shared_ptr.h:297:2: note: template std::shared_ptr<_Tp>& std::shared_ptr<_Tp>::operator=(std::shared_ptr<_Tp1>&&) [with _Tp1 = _Tp1; _Tp = foo] 1> operator=(shared_ptr<_Tp1>&& __r) noexcept 1> ^ 1>q:\buildsdk\odb\2.4.0\odb-2.4.0-i686-windows\mingw\include\c++\4.9.3\bits\shared_ptr.h:297:2: note: template argument deduction/substitution failed: 1>In file included from Q:/BuildSdk/ODB/2.4.0/include/odb/lazy-ptr.hxx:668:0, 1> from D:/Labs/ODB/lazy_pointer_hell/src/foobar.hxx:2: 1>Q:/BuildSdk/ODB/2.4.0/include/odb/lazy-ptr.ixx:1153:10: note: mismatched types 'std::shared_ptr<_Tp1>' and 'odb::object_traits::pointer_type {aka foo*}' 1> p_ = i_.template load (true); // Reset id. 1> ^ 1>In file included from q:\buildsdk\odb\2.4.0\odb-2.4.0-i686-windows\mingw\include\c++\4.9.3\memory:82:0, 1> from Q:/BuildSdk/ODB/2.4.0/include/odb/lazy-ptr.hxx:10, 1> from D:/Labs/ODB/lazy_pointer_hell/src/foobar.hxx:2: 1>q:\buildsdk\odb\2.4.0\odb-2.4.0-i686-windows\mingw\include\c++\4.9.3\bits\shared_ptr.h:305:2: note: template std::shared_ptr<_Tp>& std::shared_ptr<_Tp>::operator=(std::unique_ptr<_Up, _Ep>&&) [with _Tp1 = _Tp1; _Del = _Del; _Tp = foo] 1> operator=(std::unique_ptr<_Tp1, _Del>&& __r) 1> ^ 1>q:\buildsdk\odb\2.4.0\odb-2.4.0-i686-windows\mingw\include\c++\4.9.3\bits\shared_ptr.h:305:2: note: template argument deduction/substitution failed: 1>In file included from Q:/BuildSdk/ODB/2.4.0/include/odb/lazy-ptr.hxx:668:0, 1> from D:/Labs/ODB/lazy_pointer_hell/src/foobar.hxx:2: 1>Q:/BuildSdk/ODB/2.4.0/include/odb/lazy-ptr.ixx:1153:10: note: mismatched types 'std::unique_ptr<_Tp, _Dp>' and 'odb::object_traits::pointer_type {aka foo*}' 1> p_ = i_.template load (true); // Reset id. 1> ^ 1>Done building project "LazyPointerExample.vcxproj" -- FAILED. 2>------ Skipped Build: Project: ALL_BUILD, Configuration: Debug x64 ------ 2>Project not selected to build for this solution configuration ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 1 skipped ========== From boris at codesynthesis.com Wed Sep 15 09:38:58 2021 From: boris at codesynthesis.com (Boris Kolpackov) Date: Wed Sep 15 09:37:22 2021 Subject: [odb-users] Compile Error with Lazy Pointers In-Reply-To: References: Message-ID: EDDOWES Scott writes: > #include > #include > > #pragma db object pointer(std::shared_ptr) > class foo > { > public: > foo(int value = 0) : mValue(value) {} > ~foo() {} > > #pragma db id > int mId; > int mValue; > }; > > #pragma db object pointer(std::shared_ptr) > class bar > { > public: > bar() {} > ~bar() {} > > void SetFoo(std::shared_ptr& rpFoo) > { > mpFoo = rpFoo; > } > > bool GetFooVal(int& rValue) > { > mpFoo.load(); > if (mpFoo == nullptr) > { > return false; > } > rValue = mpFoo->mValue; > return true; > } > > #pragma db id > int mId; > odb::lazy_shared_ptr mpFoo; > }; Code that loads the lazy pointer needs to "see" definitions from the *-odb.hxx file corresponding to the pointed-to object (since load() effectively calls db.load() underneath). The simplest way to fix the above code is to make GetFooVal() non-inline and define it in foobar.cxx. Alternatively, if you want to keep it inline, you can do something like this: ... #pragma db object pointer(std::shared_ptr) class bar { ... bool GetFooVal(int& rValue); ... }; #ifndef ODB_COMPILER #include "foobar-odb.hxx" inline bool bar::GetFooVal(int& rValue) { ... } #endif From scott.eddowes at hds.leica-geosystems.com Wed Sep 15 20:16:53 2021 From: scott.eddowes at hds.leica-geosystems.com (EDDOWES Scott) Date: Wed Sep 15 20:15:30 2021 Subject: [odb-users] Compile Error with Lazy Pointers In-Reply-To: References: Message-ID: >> Code that loads the lazy pointer needs to "see" definitions from the *-odb.hxx file corresponding to the pointed-to object (since load() effectively calls db.load() underneath). >> The simplest way to fix the above code is to make GetFooVal() non-inline and define it in foobar.cxx. This worked. Thanks a lot! From naveen_kumar_v_m at baxter.com Thu Sep 16 04:49:37 2021 From: naveen_kumar_v_m at baxter.com (V M, Naveen Kumar) Date: Thu Sep 16 07:56:52 2021 Subject: [odb-users] How to install 32 bit version of odb/run time libraries Message-ID: Hello Boris, How do we install the odb and run time odb libraries for 32 bit architecture? I am using Odb_2.5.0 beta version and I would like to generate the libraries for 32bit architecture. I am following the steps mentioned here https://www.codesynthesis.com/products/odb/doc/install-build2.xhtml#linux-build2. I am working on X86_64 architecture and by default the libodb.so and libodb-sqlite.so are getting generated for X86_64. Please suggest. Best regards --Naveen From boris at codesynthesis.com Thu Sep 16 08:04:26 2021 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Sep 16 08:02:51 2021 Subject: [odb-users] How to install 32 bit version of odb/run time libraries In-Reply-To: References: Message-ID: V M, Naveen Kumar writes: > How do we install the odb and run time odb libraries for 32 bit > architecture? I am using Odb_2.5.0 beta version and I would like > to generate the libraries for 32bit architecture. I am following > the steps mentioned here > > https://www.codesynthesis.com/products/odb/doc/install-build2.xhtml#linux-build2. When creating the build configuration for runtime libraries, pass config.cxx="g++ -m32": $ bpkg create -d gcc-X cc \ config.cxx="g++ -m32" \ config.cc.coptions=-O3 \ config.install.root=/usr/local \ config.install.sudo=sudo This assumes that your C++ compiler has been built with the multi- arch support and that the relevant 32-bit runtime libraries have been installed. From specialgunpowder at outlook.com Sat Sep 25 13:03:14 2021 From: specialgunpowder at outlook.com (Special Gunpowder) Date: Mon Sep 27 10:25:25 2021 Subject: [odb-users] Compatible versions: ODB +Visual Studio + Boost + SQLite Message-ID: Hello, I have an app built with: ODB 2.4.0 (with ODB Boost and ODB-SQLite) Boost 1.5.6 Visual Studio Professional 2013 I built all the ODB libs, but for Boost I am using downloaded pre-built binaries. I would like to change to build with Visual Studio 2019 Community Edition. My question is: what versions of ODB and Boost should I use to maximize compatibility and minimize compilation problems? Can anyone give me a concrete example of a similar setup using Visual Studio 2019 Community Edition? Thanks! From boris at codesynthesis.com Mon Sep 27 10:45:28 2021 From: boris at codesynthesis.com (Boris Kolpackov) Date: Mon Sep 27 10:43:45 2021 Subject: [odb-users] Compatible versions: ODB +Visual Studio + Boost + SQLite In-Reply-To: References: Message-ID: Special Gunpowder writes: > ODB 2.4.0 (with ODB Boost and ODB-SQLite) > Boost 1.5.6 > Visual Studio Professional 2013 > > [...] > > I would like to change to build with Visual Studio 2019 Community Edition. > > My question is: what versions of ODB and Boost should I use to maximize > compatibility and minimize compilation problems? I would suggest using ODB 2.5.0 pre-release built using build2 (we test with VS 2019, you can see the CI results): https://codesynthesis.com/products/odb/doc/install-build2.xhtml Regarding Boost, I would suggest using the latest release. The ODB profile should be compatible with it (and if not, please report so that we can fix it). If you are feeling adventurous, you can get the latest Boost as build2 packages from here (until build2 0.14.0 is released, at which point they will be published to cppget.org): https://queue.stage.build2.org/ Note that in this case you will also need to use staged build2 0.14.0 pre-release (again, until it's released in a few weeks): https://build2.org/community.xhtml#stage From adnan at rihan.fr Wed Sep 29 19:34:46 2021 From: adnan at rihan.fr (Adnan RIHAN) Date: Thu Sep 30 09:54:45 2021 Subject: [odb-users] Web http client as database runtime Message-ID: <8dbdbc68-b2a4-471d-61b7-266f69705874@rihan.fr> Hi all, 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? Thanks for your advices -- Regards, Adnan RIHAN GPG: D433-5C63 (https://keybase.io/max13/key.asc) ? If you are not using GPG/PGP but want to send me an encrypted e-mail: https://encrypt.to/0xD4335C63. From boris at codesynthesis.com Thu Sep 30 10:33:00 2021 From: boris at codesynthesis.com (Boris Kolpackov) Date: Thu Sep 30 10:31:18 2021 Subject: [odb-users] Web http client as database runtime In-Reply-To: <8dbdbc68-b2a4-471d-61b7-266f69705874@rihan.fr> References: <8dbdbc68-b2a4-471d-61b7-266f69705874@rihan.fr> Message-ID: Adnan RIHAN 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. From adnan at rihan.fr Thu Sep 30 11:07:09 2021 From: adnan at rihan.fr (Adnan RIHAN) Date: Mon Oct 4 11:54:30 2021 Subject: [odb-users] Web http client as database runtime In-Reply-To: References: <8dbdbc68-b2a4-471d-61b7-266f69705874@rihan.fr> Message-ID: 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 prototypes. -- Regards, Adnan RIHAN Le jeu. 30 sept. 2021 ? 16:33, Boris Kolpackov a ?crit : > > Adnan RIHAN 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. From tony at rightsoft.com.au Thu Sep 30 10:53:46 2021 From: tony at rightsoft.com.au (Tony Rietwyk) Date: Tue Oct 5 09:41:38 2021 Subject: [odb-users] Web http client as database runtime In-Reply-To: <8dbdbc68-b2a4-471d-61b7-266f69705874@rihan.fr> References: <8dbdbc68-b2a4-471d-61b7-266f69705874@rihan.fr> Message-ID: <208802b2-1189-2db1-7f4d-b8d4e0459aca@rightsoft.com.au> On 30/09/2021 9:34 am, Adnan RIHAN wrote: > Hi all, > > 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? > > Thanks for your advices Hi Adnan, Not a direct answer regarding ODB, but I had to do something similar with a large QtSql and Firebird app used by thousands of schools around the world.? I used a home grown QSqlDriver for several reasons: - The app was too large to make any widespread changes. - The app already switched between local and LAN based database connections, so adding a third connection type was easy. - The app was very pop-up dialog based, where lists of records were modified in memory, then the insert/delete/updates for the altered records were done in a single transaction when the dialog was OK'd.? This was really lucky and important, since none of the changes relied on doing selects on altered information during the transaction.? So the updating SQL statements and bind parameters could be accumulated by the driver and sent to the cloud server in one request during the 'commit' routine.? The select statements (usually done at the dialog start) were simply passed through directly to the cloud server. - Some of the select queries could return very large amounts of data - mostly admin reports. - Many students had very low-end laptops and Internet connections, so reducing the amount of traffic to the cloud server used to be important. It took several months of development, and remains private to that client.? There were tricky issues mostly around using a nested event loop to block or delay UI interactions while accessing the network. I hope you find this useful, Regards, Tony