Questions tagged [qtsql]

Questions related to QtSQl Module, a collection of Qt classes that work with various relational database management systems.

Provides a driver layer, SQL API layer, and a user interface layer for SQL databases.

238 questions
46
votes
4 answers

How do I use alias in where clause?

Possible Duplicate: Referring to a Column Alias in a WHERE Clause SELECT Trade.TradeId, Isnull(Securities.SecurityType,'Other') SecurityType, TableName, CASE WHEN SecurityTrade.SecurityId IS NOT NULL THEN SecurityTrade.SecurityId ELSE…
Neo
  • 15,491
  • 59
  • 215
  • 405
31
votes
3 answers

What is the correct way of QSqlDatabase & QSqlQuery?

I got confused with the manual , should i work like this: { QSqlDatabase db = QSqlDatabase::addDatabase (...); QSqlQuery query (db); query.exec (...); } QSqlDatabase::removeDatabase (...); As the document points out, query or db will be…
daisy
  • 22,498
  • 29
  • 129
  • 265
19
votes
2 answers

Correctly using QSqlDatabase in multi-threaded programs

Based on the Qt documentation: A connection can only be used from within the thread that created it. Moving connections between threads or creating queries from a different thread is not supported. The question that bothers me, is what happens…
Sasa
  • 1,597
  • 4
  • 16
  • 33
15
votes
1 answer

Using SQLite with Qt

I am thinking of using SQLite as a backend DB for a C++ applicatiojn I am writing. I have read the relevant docs on both teh trolltech site and sqlite, but the information seems a little disjointed, there is no simple snippet that shows a complete…
Stick it to THE MAN
  • 5,621
  • 17
  • 77
  • 93
9
votes
2 answers

multiple sql statements in QSqlQuery using the sqlite3 driver

I have a file containing several SQL statements that I'd like to use to initialize a new sqlite3 database file. Apparently, sqlite3 only handles multiple statements in one query via the sqlite3_exec() function, and not through the…
joshfisher
  • 227
  • 1
  • 3
  • 8
8
votes
3 answers

Using QSqlQuery from multiple threads

I have a lot of C++11 threads running which all need database access at some time. In main I do initalize the database connection and open the database. Qt documentation says that queries are not threadsafe so I use a global mutex until a QSqlQuery…
Gustavo
  • 919
  • 11
  • 34
8
votes
7 answers

How to make Qt aware of the QMYSQL driver

I'm trying to access a MySql database from a Qt application but I get the following error: QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QSQLITE2 I find this very strange cause I have libqsqlmysql.so on my Qt…
Raphael
  • 7,972
  • 14
  • 62
  • 83
8
votes
2 answers

How to get the ID of a previously inserted row within a transaction using QSqlQuery

I am trying to get the primary key of an inserted row within a transaction scope, because I do not want to leave the db in a logically inconsistent state. My problem is I cannot find a way to retrieve the ID value of a previously executed query,…
average joe
  • 319
  • 4
  • 14
7
votes
1 answer

QtSql multiple query execution

... query.exec("insert into person values(104, 'Roberto', 'Robitaille')"); query.exec("insert into person values(105, 'Maria', 'Papadopoulos')"); ... Can these be bind in a single query.exec() ?
Dewsworld
  • 13,367
  • 23
  • 68
  • 104
7
votes
2 answers

QTableView + QSqlTableModel - how to read id of selected row

I'm using QTableView with QSqlTableModel. In my view I don't display the column containing record id. How can I acquire id of the selected row if its not displayed in any column ? Thanks for help :)
user666491
7
votes
2 answers

Qt 5 with SQLite: bindValue() results in "Parameter count mismatch" error

I'm doing a simple parameterized query with Qt 5.3.1 (64-bit) on Windows 7 using the SQLite driver. When I use bindValue() to set the value of the single parameter of my query, I systematically get the dreaded "Parameter count mismatch" error.…
François Beaune
  • 4,270
  • 7
  • 41
  • 65
6
votes
1 answer

Most efficient way to iterate through a QSqlQuery result set?

I'm querying a remote MSSQL Server database using QODBC and I have a result set returned but it appears as though it sends a query to SQL Server for each record one by one. This is really slow for iterating a result set. Running the query from Qt,…
Cameron Tinker
  • 9,634
  • 10
  • 46
  • 85
5
votes
1 answer

QSql module and multithreaded application

I'm troubled by how the Sql module works with multithreaded application in Qt. http://doc.qt.io/qt-5/threads-modules.html#threads-and-the-sql-module clearly states that "A connection can only be used from within the thread that…
Xaqq
  • 4,308
  • 2
  • 25
  • 38
5
votes
1 answer

Why Qt Configure can not find correct MySQL installation on target when cross compiling?

I want to build MySQL driver while cross-compiling Qt5 for Arm(Raspberry Pi). In order to check MySQL client libraries installation on target we run: pi@raspberrypi:~ $ mysql_config --version 10.1.38 pi@raspberrypi:~ $ mysql_config…
IMAN4K
  • 1,265
  • 3
  • 24
  • 42
5
votes
3 answers

QtSQL + Sqlite and support for .size() function?

I'm wondering does QtSql + Sqlite support QSqlQuery::size() function?
Sebastian Dusza
  • 2,470
  • 2
  • 30
  • 54
1
2 3
15 16