Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

generate table sql schema from QSql* classes



  • Hi.
    Is it possible to generate a sql schema from QSqlRecord and QSqlField classes? I use these classes because they are x-platform and work with any database that Qt supports.

    PS1: AFAIK there is no direct support for primary key and foreign key detection in qt. how can I implement this?
    PS2: The result schema should change based on selected sql driver. Does Qt handles this or I should create a class hierarchy for this based on sql driver?

    Thanks :-)


  • Lifetime Qt Champion

    There is no support for such stuff, but some of your information can be gathered:

    • PK: QSqlDatabase::primaryIndex()
    • Column types: QSqlDatabase::record()

Log in to reply