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
2
votes
1 answer

Error on Submit after Inserting a Row in QSqlTableModel - No Fields to update

I have a SQLite database table with the following schema: TABLE IenState ( Id primary key, NetId integer, NodeId integer, DevType text Qos integer ) Using a DB Browser utility I inserted a record in the table. I…
Jatala
  • 93
  • 1
  • 11
2
votes
1 answer

QtSQL how to read record as QMap

is there a quick way to read record from query as a QMap or similar type ? Or maybe You could tell me how to access the list of columns in current record ? Thanks.
user666491
2
votes
1 answer

PyQt5 and persistent DB with QtSql

Fairly new to PyQt5 and in setting up a sample application I ran into an issue with QtSql. All of the examples I have found show a single class using the database connection but none show how to use the QtSql classes persistently over many…
Elcid_91
  • 1,571
  • 4
  • 24
  • 50
2
votes
1 answer

QSqlQuery is only returning two columns with SELECT * FROM ..., any idea why I don't get all the columns?

I have a table with 16 columns. I perform a SELECT using the QSqlQuery class. I get two rows as expected, but only the first 2 columns out of the 16. Here is a simplified version of the query QSqlQuery query(f_db); query.prepare(QString("SELECT *…
Alexis Wilke
  • 19,179
  • 10
  • 84
  • 156
2
votes
1 answer

Can't INSERT data into database using sqlite and pyqt

I am using Pycharm 2017.3. My python version is 3.4. I am trying to insert data into table using sqlite4 and pyqt. I have successfully created a table but could not insert even a single data. Here is what I am importing from PyQt4.QtGui import…
royatirek
  • 2,437
  • 2
  • 20
  • 34
2
votes
1 answer

Qt transactions rollback fails on MySQL

I am trying to use transactions within a Qt connection but I am unable to understand how they work properly. My database is a MySQL instance and tables use the InnoDB engine so transactions are supported. I wrote a little test where within a…
paolo_tn
  • 125
  • 1
  • 6
2
votes
1 answer

How to get a QModelIndex of a row, found by a SELECT-query (QSqlQuery) without modifying the original QSqlQueryModel

I already asked the question but I was misunderstood, so I try to precicise the problem. I am using a QSqlQueryModel for showing data from a SQLite Database, for the view I use a QTableView. Now I want to implement a "Search/Find/Replace" dialog,…
philistion
  • 31
  • 4
2
votes
2 answers

Why is my sqlite query so slow in Qt5?

In Qt5.4 using QSqlDatabase with sqlite3 on Ubuntu14.04 64bit: First I open and call transaction() on the db. Next I make 54 individual insert queries, each prepared, each deleted after execution. Finally I call commit(). All calls complete without…
Mr. Developerdude
  • 9,118
  • 10
  • 57
  • 95
2
votes
1 answer

QSqlQueryModel complains that my database is not open

I am trying to use QSqlQueryModel in order to retrieve some values from my database like such: QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL", "test1"); db.setHostName(Vars::strDbHost); db.setDatabaseName(Vars::strDbName); …
dearn44
  • 3,198
  • 4
  • 30
  • 63
2
votes
1 answer

Get primaryKey programmatically with Qt

I try to get primaryKey programmatically and convert it to col name. this function not work as mast be. QString getPrimaryFiled( const QString &tableName ) { QSqlDatabase m_SqlDataBase =…
Amr Eisa
  • 33
  • 5
2
votes
1 answer

Qt SQL prepare fails

I'm trying to run this Qt code QString serverName = "localhost"; QString dbName = "zfserver"; QString userName = "root"; QString passWord = "123456"; QSqlDatabase db =…
Atef Ramadan
  • 105
  • 8
2
votes
1 answer

Updating a sqlite3 Database with QSqlQuery

I am working on a simple gui with pyqt and trying to update my database without any luck so far. I am pretty new to qt, database and well also python ;) so I don't understand whats wrong with my code, maybe some one could help me a little bit. While…
user3199535
  • 65
  • 1
  • 6
2
votes
1 answer

cx_freeze: QODBC driver not loaded

my python application looks like: test.py from PyQt4 import QtCore from PyQt4 import QtGui from PyQt4 import QtSql import sys import atexit if __name__ == "__main__": app = QtGui.QApplication(sys.argv) db =…
user2494129
  • 717
  • 2
  • 13
  • 24
2
votes
1 answer

QDataWidgetMapper and QDateEdit values

I have QSqlTableModel with some table, let's suppose that it's a model->setTable("Person"); And also I have QDataWidgetMapper which mapps some widgets (lineedits etc.) to appropriate columns in model. So the problem is in QDateEdit element.…
Daniel
  • 635
  • 1
  • 5
  • 22
2
votes
1 answer

Resolving complex foreign keys in QSqlRelationalTable

I'm working with QSqlRelationalModel and I have some problem. For example if we deal with simple tables like: Location +------+--------+ | id | name | +------+--------+ Department +------+-------------+ | id | location_id…
Daniel
  • 635
  • 1
  • 5
  • 22