What would you suggest to use in the following scenario:
Desktop application in C++
Cross platform (might use wxwidgets)
Sqlite3 DB (no concurrent accesses by different users)
Would like some kind of configurable lazy loading mechanism, meaning certain parts of an object can be loaded at different moments.
I would like to use an ORM to reduce CRUD code, is there any of them that fits the bill?
Do I need to write my own ORM?
Thank you and best regards.
ODB is a C++ ORM released under GPL (or a purchasable commercial license) that supports SQLite. It also supports lazy-loading of relationships and is cross-platform.
See http://www.codesynthesis.com/products/odb/features.xhtml for details.
Qt is an excellent cross-platform development environment, and someone's written an ORM which goes well with it.
Can you elaborate on the requirements for lazy loading?
Related
I am at the first time creating a huge program in C++ for my company and I want to create a good pattern to connect into my MySql db. I have these problems:
-I can't decide which pattern should be used, DAO,
Repository, UnitOfWork, Factory..
-I can't find a good examples of data access pattern in C++, I know it should be independently of language but I couldn't find even a robust
DAO pattern example with a good exception handling etc... Commonly are
only two classes (obj1->obj2) on very small environment.
If someone knows good sources or any tips I will be very glad =D
Thanks in advance.
My advice is search for c++ ORM(Object Relational Mapping) there are plenty ORM or DAL solutions on java like Hibernate, Datanucleus, SQLite ..
We are using Datanucleus and we are happy with it but i dont think datanucleus have a support for c++. Imho creating DAL form scratch is unnecessary.
I had the same problem years ago. The list of ORM for C++ in Wikipedia is very short and the most promising product is under GPL or you have to buy it.
We decide to develop our own ORM. There are several enterprise design patterns for it. We choose the way obd uses: Your tables was described from simple classes. The persistence and access of objects are handled from an database-manager. The most costliest todo is to write your own query-interface (if you don't wand to type clear sql in your code).
I want to create an app based on the content of a .mdb file, I searched for libraries to do that in native but they all needed requirements, I want a way to read these files using native code(C++) only, so I could use the library in multiple platforms.
Thx,
Regards
The .mdb file format is specific to the Microsoft Access ("Jet") database engine, which is proprietary and specific to Windows. (Furthermore, it is an evolving file-format, although it does not seem to continue to be in active development now.) There is one, and only one, "correct" way to use it, and that is: to use Microsoft's library and surrounding framework, on Microsoft's operating system.
If, indeed, you need to use a "file-based SQL engine," "on multiple platforms," then I would cordially suggest that you instead use a database file format that was specifically designed for such purposes: SQLite.
Mind you, the two are not the same. They're the product of two entirely different design teams who had different purposes in mind. The SQLite team knowingly did not adhere strictly to the SQL standard. But, what they did do was to create a public domain(!) database engine, which uses a single file, and which was specifically designed to be cross-platform. Meanwhile, the Jet team designed their engine specifically, and solely, in support of the Access (and Excel) products of their company.
I am looking for a way to connect to an remote oracle database and read some data from table within a c++ console application.
Can some one give me some hints.
Thnx.
soci, http://soci.sourceforge.net, is a reasonably modern C++ interface that uses the Oracle call interface. And can also connect to other databases ...
The official Oracle website proposes several resources. Amongst others:
Oracle C++ Call Interface
Develop C and C++ Applications with Oracle Database 11g Using OCI
Just google, there are really plenty of tutorials around.
You can either use the Oracle C++ Call Interface (native API) or the Open DataBase Connectivity API. If you want a more high-level wrapper, there are some more convenient interfaces in libraries such as Qt.
Unless it's study purpose or strict requirement with ORACLE DB, I'd suggest you to work with generic classes/services provided with various Microsoft Framework.
Data Access Programming
MFC Database classes
ATL Database classes
Of course ORCACLE C++ IF is also available.
You can use OCCI: http://www.oracle.com/technetwork/database/features/oci/index-090820.html
or OCI: http://www.oracle.com/technetwork/database/features/oci/index.html
or one of many other APIs available.. It really depends on the type of thing you're going to use it for.. You should find a lot of information about the pros/cons of the various APIs through google..
You can try: CODBC. It is an API for Pro*C. Pro*C is a very decent way to connect Oracle and C++.
Currently (2021) actively developed is also OCILIB, I was able to setup the test example in short time.
Does anyone have a recommendation for an ORM for qt4 (c++)? (Like a Django ORM).
I would suggest you take a look at the QDjango ORM, it might be just what you are looking for. This C++ ORM only depends on Qt and builds upon Qt's Meta-Object System to provide introspection. On top of the basic create/update/delete operations at the model level, it provides a queryset template class (modeled after django's querysets) which allows to build fairly complex lookups.
Optional QtScript support is also provided, so you can access your models and perform database queries from scripts.
There is also a new open source ORM C++ library : QxOrm. QxOrm is based on QtSql Qt module to communicate with database and boost::serialization to serialize your data with xml and binary format. The web site is in french but quick sample code and tutorial code is in english (a translation is in progress...).
I'm willing to write a subset of Perl's DBI interface for libodbc (or unixODBC) in C++.
I believe doing so will allow me concentrate better on my goal.
BTW, I prefer avoiding to reinvent the wheel, if of course something similar is already out there.
NVM, no odbc interface, but it is DBI like (seeing as DBI doesn't use odbc except in DBD::ODBC)
libdbi - http://libdbi.sourceforge.net/
libdbi implements a
database-independent abstraction layer
in C, similar to the DBI/DBD layer in
Perl. Writing one generic set of code,
programmers can leverage the power of
multiple databases and multiple
simultaneous database connections by
using this framework.
In order to utilize the libdbi
framework, you need to install drivers
for a particular type of database. The
drivers officially supported by libdbi
are split off into the libdbi-drivers
project. The current version of libdbi
(0.8.3) is supposed to work with any
0.8.x release of libdbi-drivers. Currently the following database
engines are supported:
* Firebird/Interbase
* FreeTDS (provides access to MS SQL Server and Sybase)
* MySQL
* PostgreSQL
* SQLite/SQLite3
I don't know a DB API that looks like DBI. Go for it - but add it to the libodbc project as a wrapper API rather than start a brand new project.
good luck.