Can't get fields' default values from mysql database
-
wrote on 25 Feb 2024, 04:39 last edited by
I'm using PyQt6 connecting to MySql v8 database. I created a
QSqlRelationalTableModel
then aQDataWidgetMapper
to map a record to some widgets. I insert a new record to the model, then position the datawidgetmapper to that record. I don't get the default values from the database in the widgets.
I tried to print themodel.record().field(i).defaultValue()
I always get None for all fields.
I tested it with sqlite and it works. Though, when I insert a new recordmodel.record()
I don't get the default values. BUT when I get the record from database (Sqlite)QSqlDatabase.record(tableName)
I get the default values automatically.
Any thoughts how could I fix that? -
Hi and welcome to devnet,
Can you provide a minimal runnable example with a test database to reproduce this ?
1/2