[Qt-interest] QtMonoDB table model

Martin Holst Swende martin at swende.se
Mon Dec 6 14:36:19 CET 2010


On 12/06/2010 02:15 PM, David Boddie wrote:
> Martin Holst Swende wrote:
>
>> I don't want to reinvent the wheel, and I think that a MongoDBTableModel
>> could probably reuse a lot from the SQL-libraries. Where can I find the
>> source code for them? I am a bit new to the c-side of Qt (coming
>> straight from PyQt and have never written a line of "pure" Qt.)
> If you haven't already seen it, you might want to take a look at the
> DbAPICursorModel class in this collection of examples (in the
> sqlcursorview.py example):
>
> http://pypi.python.org/pypi/EuroPython2006_PyQt4_Examples/1.0
>
> I didn't write it, and haven't looked very closely at the source code for
> it, but it might help you get started with writing your own model.
> An alternative is to look for an existing Python DBAPI adaptor for MongoDB
> and build on the DbAPICursorModel model to add the features you need.
>
> David
Thanks for the tip,

I took a quick look at it. It basically does this:
    def setResultset(self, cursor):
        self._resultRows = cursor.fetchall()
...
query.execute("SELECT * FROM person")
model.setResultset(query)

==> It executes the query and stores the complete result in memory. It
is the same way I already do it, I was hoping to find something which
could scale better from two aspects :
1) Handle large amounts of data by keeping as little as needed in memory
2) Keep "trailing cursors" (or whatever it is called), where the
connection to the database is kept open and new data which is added can
be sent directly to the results without the need for the caller to
perform a new full query. This is supported in MongoDB, and is a very
nice feature for real-time monitoring of data.

I'll keep looking,
/Martin



More information about the Qt-interest-old mailing list