166 questions
2
votes
0
answers
100
views
PySide6 subclassing QSqlDatabase
I've run into an issue with PySide6 that I cannot subclass QSqlDatabase.
My biggest complaint about the QtSql system is that it does not throw exceptions when things go wrong. You have to manually ...
1
vote
0
answers
29
views
QtSqlDatabase can't connect to MySql from inside debugger
Im writing a C++ program using QtCreator, Qt 6.9.0 and llvm-mingw1706_64 in Windows11.
It is an user interface toward a MySql database.
If I run the program normally, it can access database with no ...
0
votes
0
answers
47
views
QSqlTableModel (SQLite): Values of modified record are stored in model, but are not written to database on submitAll
I have an application (Qt 5.15.2) where values of an QSqlTableModel are modified by
Retrieving a copy of the record with QSqlTableModel::record(int row)
Modifying values with QSqlRecord::setValue(int ...
2
votes
0
answers
41
views
How do I get a list or array data type out of PyQt5 QSQLQuery using PostgreSQL database?
I have a basic database setup using postgresql. One of the columns has a real[] data type set, but no matter what I do the resulting value from a qsqlquery returns a string type instead of an array or ...
0
votes
1
answer
109
views
QMYSQL Plugin Available But Still Get "Driver not loaded"
I'm writing a C++ app with Qt that needs to connect to a MySQL database. I can't seem to get QSqlDatabase to actually load the actually available QMYSQL plugin.
Qt 6.7.2. on Mac (macOS 12.7.6, x86_64,...
0
votes
0
answers
65
views
Why is a global thread_local object get deleted during a Qt ui initialization?
I'm writing a QT program with a lot of database queries.
The QSqlDatabase is not thread safe as the documents states.
So I wrote a simple thread_local QSqlDatabase to maintain a database connection ...
0
votes
0
answers
60
views
error closing the connection to the SQL database due to a query in Qt6/C++
my code outputs the error
QSqlDatabasePrivate::removeDatabase: connection 'createRequestConnection' is still in use, all queries will cease to work.
although there is not even a QSqlQuery query, I ...
1
vote
0
answers
171
views
PyQT and SQLite with multiple users
We are trying to write concurrently to a SQLite database, using WAL mode, to a network location. We don't have the privileges of having a server-based database (Postgres, MySQL, etc) so we have to ...
0
votes
1
answer
50
views
What do I have to include in my release Qt gui package to run the sqlite db?
The debug version of my project runs perfectly and the release version also runs except for the sqlite code. I get the following error messages: "QSqlDatabase: QSQLITE driver not loaded. ...
0
votes
1
answer
551
views
How can QMYSQL driver be loaded?
In How to solve "QSqlDatabase: QMYSQL driver not loaded", this answer says that libqsqlmysql.a and libqsqlmysqld.a files should exist in <QtDir>\mingw73_xx\lib folder.
But I cannot get ...
1
vote
0
answers
407
views
Handling reconnection of MySQL (MariaDB) database without MYSQL_OPT_RECONNECT
Currently I have this code:
Orders::Orders(QObject *parent) : QObject{parent}
{
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL", "orders");
db.setHostName("...
0
votes
0
answers
172
views
Getting SQL_HANDLE_HENV failed error only after a disconnection
I found other similar questions with the same error (i.e. this and this) but apparently all of them are related to a wrong library / configuration since the users cannot connect to the database at all....
-1
votes
1
answer
84
views
How to add new rows in a database?
I am creating a simple app for modifying SQLite databases.
I am trying to add new rows in MainWindow::on_AddButton_clicked() method, but when I use the MainWindow::on_reselectTable_clicked() method ...
0
votes
1
answer
274
views
How to use QSqlDatabase to import database from disk to in-memory?
I want to import a database from disk to memory at application start and on exit export back from memory to disk. I converted this code from C++ to Python. It successfully exports the database from ...
1
vote
0
answers
208
views
QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
I wanna make a MySQL database mapping to QTableView but i got this error:
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3 QODBC QODBC3 QPSQL ...
0
votes
1
answer
232
views
How to handle if database is already open in Qt?
The problem is that the database connection can be unstable, so at the beginning of the program it is easy to check this with if(!db.open()). But some cases can happen while the application is running....
0
votes
0
answers
48
views
Why are the rows missing? QTableView + QSqlRelationalTableModel [duplicate]
I can't figure out the strange display behavior of QSqlRelationalTableModel.
setEditStrategy of the model is set to OnFieldChange. I'm trying to change the values in the cells, but the whole row ...
0
votes
1
answer
175
views
QSqlDatabase connection
I have a server with a MariaDB Database.
Then I have a python program who run in a client where I have this code:
def Connect():
# Credential reading from register
servHost = RegRead(&...
1
vote
0
answers
475
views
How to start an immediate transaction of Sqlite in Qt?
Got troubles with using QSqlDatabase::transaction().
I want to start a transaction of Sqlite in Qt and I know this function : bool QSqlDatabase::transaction():
if(db.transaction())
{
QSqlQuery ...
1
vote
0
answers
911
views
How do you load an SQLite3 database file into using PyQt6.QSQL?
I'm playing around with PyQt6 and QSQL.
The code down here was meant to load a sqlite3 database into a QTableView
But instead, it will load only the headers of a table into the table view.
What do I ...
0
votes
0
answers
236
views
Opening Excel to read using QSqlDatabase
I can open the XLSX Excel format and read all data but only if the code for it is part of the constructor of the QMainWindow. For first tests to read the Excel it was fine. But when I move the ...
1
vote
1
answer
347
views
How to read the headers of a .txt files and put them as headers of a QTableView
I have a small problem trying to propoerly parse a .txt files and show its content on a QTableView. Specifically how to extract the headers of the file and show them into a QTableView.
The .txt file ...
1
vote
0
answers
144
views
How to send postgresql notifications via PyQt5 QSqlDatabase?
I am writing a pyqt5 qui that interfaces with my psql DB via SQslDatabase. External-to-me processes have a listen/notify setup to communicate status to other components via the database. So, my gui ...
0
votes
1
answer
233
views
How to create a database table if the fields are declared at run time?
When creating table at run time using qsqlquery the fields of the sqlite database table are declared by user, and using that I want to create a table at run time.
How can I do that in qsql cpp?
...
0
votes
1
answer
167
views
Using database name before table name in QSQLITE C++
I am using c++ QSQLDatabase (SQLITE driver) to interact with an sqlite3 database. The c++ code uses queries that have the database's name before the table name like this :
SELECT *
FROM database_name....
0
votes
1
answer
263
views
How can I catch a unique constraint violation through QSqlDatabase?
I have a Qt application, using QSqlDatabase, and I need to take a different action on a unique key constraint violation as opposed to any other type of error.
Currently, the backend database is SQLite,...
0
votes
1
answer
402
views
Why QSqlDatabase object won't work if addDatabase method assigned later?
This won't work:
{
QSqlDatabase db;
db.addDatabase("QSQLITE", "manDb");
QString path = QDir::currentPath()+"/"+"Sqlite.db";
db.setDatabaseName(...
0
votes
1
answer
162
views
Qt QPSQL QSqlDatabase: named connection fails
I am trying to have multiple QPSQL QSqlDatabase connections in my application.
When I use only one connection - default/ no name, - it works flawlessly.
But as soon as I try to create a named ...
0
votes
1
answer
166
views
Specify database path for QMYSQL
Qt 6.2.0, Ubuntu 21.10.
Usually MariaDb stores database under /var/lib/mysql/ directory.
I can connect to my own database using this working code:
_db = QSqlDatabase::addDatabase("QMYSQL", &...
-1
votes
1
answer
46
views
I'm trying to extract month from date which looks like this "2008-08-17 00:00:00"
This is an example,Im trying combine two tables here which are db_match and country as you can see but I need to extract just month from the whole date so what could I try here ?
I tried,
update ...
1
vote
0
answers
35
views
Qt QSql: cannot create a new MDB-File per ODBC
I am using the following code to create an NEW MS Access file using the SQL API from Qt.
QString strDatabaseName;
if (strExt == ".DB")
{
oQtDatabase = QSqlDatabase::addDatabase(_TN("...
1
vote
1
answer
228
views
Python Insert Data from Qtable Widget into Ms Access with QSqlDatabase
This is what I have so far:
def save_invoice(self):
con = QSqlDatabase.addDatabase("QODBC")
con.setDatabaseName("C:/Users/Egon/Documents/Invoice/Invoice.accdb")
# ...
0
votes
0
answers
26
views
Where to find PyQt5 drivers? [duplicate]
I can't access the SQL related drivers in PyQt5. I need said drivers to do everything.
I installed PyQt5 with Anaconda
I started with code to create the connection, check that the connection works, ...
0
votes
0
answers
365
views
How to save QVariantMap into QSqlDatabase
I've already got an infrastructure to work with. There is an insert function given with the following signature:
insert(const QString& key, const QVariant& value)
Within the function the ...
0
votes
0
answers
885
views
PyQt - "QSqlDatabase: QPSQL driver not loaded" on Windows, works on OSX
I'm trying to connect to a PostgreSQL 13 database from PyQt/PySide.
When I get to con = QSqlDatabase.addDatabase('QPSQL'), I get the following console output:
QSqlDatabase: QPSQL driver not loaded
...
0
votes
2
answers
1k
views
What is the correct way to open and close a database connection for a Qt worker thread
I'm working on a scenario where we want to asynchronously execute INSERT/DELETE statements on a database table (it's a fire-and-forget scenario). I'm planning to simply fire a signal with relevant ...
0
votes
1
answer
2k
views
QSqlDatabase lastError() returns empty string for error in query
I was writing simple code using SQLite database in Qt:
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
QSqlQuery query;
query.exec("CREATE TABLE IF NOT EXISTS test(id, name)&...
1
vote
1
answer
195
views
What could be the reason why QSQLITE ATTACH DATABASE is hanging
I'm struggling on a very uncommon failure. I had a program running which attaches a configuration database to a production database. I used the ATTACH DATABASE command from sqlite. It was working fine ...
0
votes
1
answer
220
views
PyQT5 : SpinBox values are not maintained in qsql
Work on a project and I want to make spinBox values saved in the database .. but the code does not work for me ..
The result I want to get:
For example, when changing the value of spinBox_1 to 5 and ...
1
vote
1
answer
84
views
How to concatenate three feilds records from one sqlite table and insert that in to one feild of the second table?
Below is my example code:
from PyQt5 import QtCore, QtGui, QtWidgets, QtSql
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtSql import *
import sys
...
0
votes
0
answers
1k
views
"QSqlDatabase: QPSQL driver not loaded" when trying to create a database using QtSql in Python
I am trying to create a PostgreSQL database with PyQt5.
After creating a database using QSqlDatabase.addDatabase(), calling lastError().text() on that object returns the following:
Driver not loaded ...
1
vote
1
answer
2k
views
Conditional Group By on Selected rows in KDB/Q-Sql
I have a requirement where I have to execute multiple queries and perform group by on a column with where clause , group by column is fixed and where condition will be perform on fixed column with ...
1
vote
2
answers
460
views
KDB/Q-sql Dynamic Grouping and con-canting columns in output
I have a table where I have to perform group by on dynamic columns and perform aggregation, result will be column values concatenating group-by tables and aggregations on col supplied by users.
For ...
1
vote
0
answers
1k
views
Qt QSqlDatabase QSQLITE driver not loaded error
I am getting the driver not loaded error when trying to open an sqlite
database with Qt 5.15.0 on Windows.
Here is my output: QSqlDatabase: QSQLITE driver not loaded QSqlDatabase: available drivers: ...
0
votes
1
answer
478
views
Create a new column with date based on 3 other columns (year, month, day)
Is there anyway to join 3 columns to create a new column with the date value
I have a column name
Month
Day
Year
and I need to join them and show the date result of the values form those columns
2
votes
1
answer
324
views
PyQt subclassing QSqlDatabase to make exceptions
I love all of the goodness you get from QSqlDatabase and QSqlQuery and various models. But I would really like exceptions to be thrown when errors occur. So I thought maybe I could subclass ...
0
votes
0
answers
782
views
Should I explicitly call QSqlDatabase::removeDatabase or close?
I created db handling class with Qt's SQL :
// constructor of my db handler class
DBHandler::DBHandler(QObject *parent) : QObject(parent)
{
QSqlDatabase db = QSqlDatabase::addDatabas("QMYSQL", "...
0
votes
0
answers
279
views
fast way to update 10M record in Mysql database using QT
I have a 500MB file which contains a data that I need to use it to update a table that contains 10M rows so I use this code in using QT SQL library
QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"...
-1
votes
1
answer
632
views
Python: PyQt5 table with SQL - Postgrees
im writing a code in python and i need to fil a table with a database select, and also refresh it every 5 minutes, dos anyone can help me with it? i already tryied alot of ways, but none was right.
...
0
votes
1
answer
119
views
How to cancel QSqldatabase::open immediately in a running thread?
I have a Thread, which opens a database and emits a signal. The main idea is to check if the database is still there and valid. If the database is offline (MYSQL), QSqldatabase is trying for about 3 ...