[Qt-interest] Database abstraction with QSqlQueryModel
Neville Dastur
qt at dastur.me.uk
Tue Aug 24 23:44:44 CEST 2010
On 24/08/10 19:19, Andre Somers wrote:
> Op 24-8-2010 20:11, Neville Dastur schreef:
>
>> Just checking I've got this right and not missing something.
>>
>> The QSqlQueryModel doesn't seem to support full database abstraction. So
>> what I mean by this is parameters etc. QSqlQuery on which it is based
>> has bindValue(), but this is not implemented in QSqlQueryModel and so I
>> have to code my own quoting and escaping of of data values? Also can't
>> seem to find a way to use QSqlQuery to generate a sql statement that I
>> can then pass to QSqlQueryModel.
>>
>> Is this right, before I post an item on Qt bug tracker.
>>
> SQL query construction is unfortunately a bit hidden and not very well
> documented. However, it is available. Take a look at
> QSqlDriver::sqlStatement(). It allows you to construct (basic) DML
> statements. Escaping of values is also available from QSqlDriver, and
> automatically done if you use sqlStatement.
>
Thank you. I think I can do what I need to from that. However, with all
this already coded you would have thought it would be built into the
standard models. Maybe, time for my first patch.
Neville
More information about the Qt-interest-old
mailing list