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...).
Related
I have been using Django for many years (since Django 1.2). and in the past, I used different type of web frameworks (such as CakePHP, Rails, ASP.NET MVC, and some other full-stack framework). Django wasn't my first framework.
Different frameworks have differences in their approaches and benefits. There are certain part of those framework I like and I don't. In this context, I'd like to look at the design of Django Framework in more specific.
After transition to Django, I like how it design its framework. When learning a new language (such as Go, Scala, Ruby, Haskell), I try to looks for a framework that has some similarity in its design especially those I mentioned later.
The following are the 2 Django framework design decision that is very different:
it encourage pluggable apps or apps reusability.
Hence:
moving away from monolithic design by Jacob Kaplan-Moss
using multiple apps to create a full feature site, without any model or logic
writing a Project-less Django mentioned in Practical Django Projects by James Bennett
it uses Model View Template instead of classical MVC:
mentioned in FAQ.
view describes which data is presented
template describes how the data is presented
a view normally delegates to a template
controller is probably the framework itself: the machinery that sends a request to the appropriate view, according to the Django URL configuration.
I would not believe that Django pioneer such features. I believed this pattern is very common in Framework Design. Just that I have no idea, what is this (design) pattern called? This concept is very useful to be applied in other framework. I believed knowing the name of the pattern could help me understand or even build a new framework on different language with the same concept.
Currently there are tons of web framework, most of them are following the classic MVC pattern. Some use the concept of plugin to add certain capability. Plugin however solve the reusability in different approach depending on the context.
So I did tried to learn as many framework I could in order to find an alternative framework in different languages. Hoping that I could find out the pattern that Django use. However, it is very difficult for me to learn all of them. In fact, I haven't found one so far.
I have been searching for:
Django like framework in 'ruby'
Django like framework in 'Java'
Django like framework in 'Haskell'
Django like framework in 'Go-Lang'
Django like framework in 'Scala'
Unfortunately, none of them really, highlight the concept that I'm interested in.
In this Q&A, I would like to know what do people call such framework? (Or What pattern is Django use?) Would be good if you could give a references in this design which other framework might have been using it too?
Looking at Django design philosophies
I think they use/combine a lot of different design patterns trying to fulfill the philosophies. It's difficult to map to a single concept.
Tip is to look at Software Design Pattern and it should be possible to identify many patterns are used in django. Many patterns are of course common in other frameworks as well.
For example (patterns more or less used):
modelform_factory maps to "Builder"
QuerySet can be mapped to "Lazy initialization"
The ORM/database mapped to "Adapter"
What is it about django that you cannot do in other languages?
is it the access to the database, or the models? - no, python also has SQLAlchemy; ruby has Active Record...
is it the views, or web framework? - no, you can provide views with Flask, Pyramid, rails, php ...
it is the templating system? - no, you also have Jinja; mustache, Liquid...
is it the admin contrib packages? - no, you have phpmyadmin, workbench ...
is it a set of libraries to make your development easy? a toolkit?
django has great tooling, many packages you can use; it is a platform, meaning it has enough of a core to be the starting point of many projects, and enough community behind it to have many packages to make integration into a turn-key solution a breeze.
django uses the DRY (Don't Repeat Yourself) principle as a design philosophy. From the point of reusability, keeping clear responsibilities for each piece / app makes it easy to reuse components. But that doesn't take a well-designed platform; the emphasis should be on the components that are written in a way to be reused. E.g. generic tagging, configuration / data-driven components...
Django is MVC.
MVC is a pattern not a strict rule frameworks have to apply. The pattern tries to give a commonly accepted solution to a frequent problem. The problem is "How to properly organize a web framework" and the solution is "by separating data, logic and UI" in meaningful modules.
Therefore Django is MVC. Django logically separates those concepts (and many others) in modules. That's what matters IMO. Django view is not the same as MVC view, but... poteto potato...
About app reusability:
Django is The web framework for perfectionists(...) and perfectionists (or simply good developers) write reusable code. This is expressed by Django DRY philosophy and materializes in Django apps.
I'm pretty sure you can design app-like components with other web frameworks. Of course, since apps are in Django's nature since many years, it has much better support!
I've used Qt for some time and now I want to try Gtk. I want to write simple database application, but it looks like there is no support for sql (I'm forced to fill manually model with data). In Qt we have QSqlQueryModel and QSqlTableModel, QTableView and QTreeView. Gtk approach is more like QTableWidget and QTreeWidget. I need somehow connect to the database, get data and fill the model. Ok, but what if my table is really big? How can I implement in-place editing (Gtk model can't modify data)? Can I chain models to provide filtering like QSortFilterProxyModel? These are basic things that I use all the time writing database applications with Qt. How this can be done with Gtk?
GTK+ is more modularized than Qt, so you'll need to look up your requirements in the GObject ecosystem. libgda is what you are looking for.
Here is a non-exhaustive overview of the platform for future references.
GTK literally stands for GIMP Toolkit. It's pretty much a purely graphically set of tools for developing GUI applications, Qt on the other hand is a graphics and a whole other stack on top for databases and so on. Your best starting point is working out what DB you're going to use, then getting the development package (if it has C++ bindings), and go through the API docs for it and you'll mostly be building the functionality on your own. There's other database abstraction layers out there, so that's another route you could take.
I was looking for an RDF project for django and I cant find any active.
This seems to be a good one http://code.google.com/p/django-rdf, but the last commit was in 2008, (4 years ago). The group in google-groups seems to be abandoned. Last no-spam post was in 2008.
Therefore it has no support for new django versions.
Is there any library or some prebuilt open source app to easily expose rdf data?
Maybe is easy to solve, like writing a view and returning something using https://github.com/RDFLib/rdflib in one or two lines of code, but I can't figure it out how to do it...
The idea using RDFlib would be to take a django object or collection of objects and transform it to rdf in some way, maybe using an rdf parser.
I thought I could give html responses if the client request "accept:text/html", and RDF if the user requested the same page using a html accept header with rdf+xml or rdf+turtle (and it could exist an app that handles that for me)
From what little I've read of RDF you are probably going to have to do manual work to get meaningful RDF statements from Django models since it's not a simple data representation format like JSON, it is trying to encode semantic meaning.
That said, have a look at django-rdflib:
https://github.com/odeoncg/django-rdflib
There doesn't seem to be any documentation (and it seems to have been built for a specific app) but the author has posted here about a manage.py syncvb command that generates an RDF graph from existing Django models:
https://groups.google.com/d/msg/django-rdf/14WVK7t88PE/ktAKJo-aCfUJ
Not sure exactly what views django-rdflib provides, but if it can make an RDFlib graph for you then you can probably use the serialization plugins provided by RDFlib to output rdf+xml or whatever from your own view.
http://code.google.com/p/djubby/
SURF is useful as a RDF->object mapper (or RDFAlchemy)
injecting rdfa into your templates should work either (if you want to avoid triplestores)
you can also expose your database as a sparql endpoint using a tool such as http://d2rq.org/
I would like to do bidirectional Model2Model transformations. Both models are EMF / eCore based. Actually I would prefer that one model is an editable view on the other.
What are my options?
Which tools and tranformation languages are avaiable and what are their restrictions?
M2M are the hardest. Industries strength tools are rare, lots of academia stuff. If you're dead set on a M2M language, look into ATL which should also support ecore. Otherwise you can look at Xtend, which was made for model to text but you can abuse it and it should be more comftable than plain java. If your into research look at Scala based transformations here
http://metrikforge.informatik.hu-berlin.de/attachments/download/193/george_wider_scheidgen_ICMT_2012.pdf
There are more transformation tools than you can imagine for EMF, its kind of crazy...
For metamodel to metamodel transformation where the models are not very similar:
ATL is probably the most popular and most "baked"
Epsilon project has the Epsilon Transformation Language.
If the metamodels are very similar and you only need to tweak some things then there are tools targeted that type of migration/updating:
ATL now has a refining mode
Epsilon has Flock
Edapt looks very interesting as well because it does the metamodel/model changes together. It lets you work on a tree view and comes with a set prebuilt set of rules.
Henshin which lets you operate on a diagram view of the model
EMF Refactor is a more code-level approach, that can also use Henshin rules somehow.
You can always directly manipulate the metamodel and model using the EMF Java APIs as well.
I'll add, if you are doing any real EMF work you will need to get and read EMF: Eclipse Modeling Framework. It's available in Safari also. I highly recommend Safari, for $39 a month you get almost every development ebook you could ever use.
If you insist on doing bidirectional M2M transformations, (so-called Bxs), then know that there is an active researcher's community updating that wiki : http://bx-community.wikidot.com.
If you visit it, you will find that they list a bunch of tool suitable for Bx transformations http://bx-community.wikidot.com/relatedtools.
I used ECHO in the past which provides an implementation of QVT-R based on the KodKod constraints solver.
It's definitely worth giving it a try.
Since you specifically asked for bi-directional model transformations, I must say that you have no options. To make it claer, adding to the answer you got form Ed Willink, none of the existing M2M transformation languages (AFAIK) supports bi-directional model transformations.
Work on a QVTr and QVTc execution engine is starting to look promising if you are still interested in this: QVTd Project.
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?