Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPSQL: Unable to create query
Forum Updated to NodeBB v4.3 + New Features

QPSQL: Unable to create query

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 2 Posters 1.4k Views
  • 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.
  • Christian EhrlicherC Offline
    Christian EhrlicherC Offline
    Christian Ehrlicher
    Lifetime Qt Champion
    wrote on last edited by
    #4

    The table is 'account', the schema public - try without schema

    Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
    Visit the Qt Academy at https://academy.qt.io/catalog

    M 1 Reply Last reply
    0
    • Christian EhrlicherC Christian Ehrlicher

      By looking what this error means: https://www.postgresql.org/docs/10/errcodes-appendix.html

      Try to run your query directly with psql to see where exactly the error is.
      Also there is no need to use prepare() here since you don't bind any values.

      M Offline
      M Offline
      Mikeeeeee
      wrote on last edited by
      #5

      @Christian-Ehrlicher Can there be a problem with a bad driver?

      1 Reply Last reply
      0
      • Christian EhrlicherC Christian Ehrlicher

        The table is 'account', the schema public - try without schema

        M Offline
        M Offline
        Mikeeeeee
        wrote on last edited by
        #6

        @Christian-Ehrlicher it is too not work:

        QSqlQuery query("SELECT *  FROM account ", dataBase);
        
        
            if (!query.exec()) {
                qDebug()<<"not get data from db \r\n"<<query.lastError()<<"\r\n";
            qDebug()<<query.lastQuery();
            }
            else {
                qDebug()<<"get data from db \r\n";
                query.first();
        
        
        
            }
            return resultVector;
        
        1 Reply Last reply
        0
        • M Offline
          M Offline
          Mikeeeeee
          wrote on last edited by
          #7

          I use psql 12 in the windows 7 64

          1 Reply Last reply
          0
          • Christian EhrlicherC Offline
            Christian EhrlicherC Offline
            Christian Ehrlicher
            Lifetime Qt Champion
            wrote on last edited by
            #8

            So where do you get the error? during query.exec()? And what error? The same as in the first post?

            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
            Visit the Qt Academy at https://academy.qt.io/catalog

            1 Reply Last reply
            0
            • M Offline
              M Offline
              Mikeeeeee
              wrote on last edited by
              #9

              @Christian-Ehrlicher said in QPSQL: Unable to create query:

              query.exec()

              Yes, in query.exec(). The same error. Looks like it's the driver. How do I find out which version of the driver is designed for?

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Mikeeeeee
                wrote on last edited by
                #10

                Do you connect PSQL to the project and it works normally?

                Christian EhrlicherC 1 Reply Last reply
                0
                • M Mikeeeeee

                  Do you connect PSQL to the project and it works normally?

                  Christian EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #11

                  @Mikeeeeee I'm using psql since ages with Qt. Imo it's a problem with your psql installation. Simply test it with a sqlite database. Also you should take a look what others did to solve the psql 42601 error but that's not Qt related

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    Mikeeeeee
                    wrote on last edited by
                    #12

                    Before the update, I had PSQL working, after the update, new drivers were added and it stopped working.

                    1 Reply Last reply
                    0
                    • Christian EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #13

                      Thenswitch back to the old PostgreSQL - or do you really need some new features in PostgreSQL 12 (btw: psql 12 is supported since Qt5.14 and works fine here)

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      1 Reply Last reply
                      1
                      • M Offline
                        M Offline
                        Mikeeeeee
                        wrote on last edited by
                        #14

                        Sorry, I'm in a connection indicated is not the base, my stupid mistake.

                        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