Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Can't get fields' default values from mysql database

Can't get fields' default values from mysql database

Scheduled Pinned Locked Moved Unsolved Qt for Python
2 Posts 2 Posters 347 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    embabi
    wrote on last edited by
    #1

    I'm using PyQt6 connecting to MySql v8 database. I created a QSqlRelationalTableModel then a QDataWidgetMapper 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 the model.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 record model.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?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Can you provide a minimal runnable example with a test database to reproduce this ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved