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. Create firebird database programmatically with Qt
Qt 6.11 is out! See what's new in the release blog

Create firebird database programmatically with Qt

Scheduled Pinned Locked Moved General and Desktop
16 Posts 2 Posters 7.9k 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.
  • guidupasG Offline
    guidupasG Offline
    guidupas
    wrote on last edited by
    #5

    Hello SGaist!

    Yes, I have the credentials but I dont figure out how to do that once QSqlDriver does not have it statement type.

    How could I do that?

    Att.
    Guilherme Cortada Dupas

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

      Can you post the statement that you want to execute ?

      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
      • guidupasG Offline
        guidupasG Offline
        guidupas
        wrote on last edited by
        #7

        I must execute a CREATE DATABASE because I need to create a database from the Qt code, but QSqlDriver does not have a create statement.

        @
        QString queryString;
        queryString += "CREATE DATABASE";
        queryString += " '" + path + "'";
        queryString += " USER 'sysdba'";
        queryString += " PASSWORD 'masterkey'";
        queryString += " DEFAULT CHARACTER SET UNICODE_FSS";
        @

        Att.
        Guilherme Cortada Dupas

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

          Looks like there's a \ missing after sysdba

          What error are you getting ?

          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
          • guidupasG Offline
            guidupasG Offline
            guidupas
            wrote on last edited by
            #9

            Yes SGaist, but the error don not appear in this code. Is is just what I need to create. The error appears when I try to run the code below:

            @
            bool DB::conectarServidorFirebird(QSqlDatabase db)
            {
            bool retorno = true;

            db.setHostName("localhost");
            db.setPassword("gui080381");
            db.setUserName("sysdba");
            //db.setPort(3050);
            
            if(db.open())
            {
                retorno = true;
            }
            else
            {
                qDebug() << db.lastError();
            
                retorno = false;
            }
            
            return retorno;
            

            }
            @

            It returns me the error:
            QSqlError("-901", "Error opening database", "Can't access lock files' directory /tmp/firebird")

            Att.
            Guilherme Cortada Dupas

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

              Do you have the rights to access /tmp/firebird ?

              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
              • guidupasG Offline
                guidupasG Offline
                guidupas
                wrote on last edited by
                #11

                No. I dont think so. But my problem is that I intend to use this database embedded and the user of my software will not have a Firebird group to be inserted in.

                There is some configuration to be made to change permissions?

                Att.
                Guilherme Cortada Dupas

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

                  What's your exact target setup ?

                  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
                  • guidupasG Offline
                    guidupasG Offline
                    guidupas
                    wrote on last edited by
                    #13

                    I need to create a database using Qt programming with any user that uses the software in any folder it wishes.

                    Is it possible?

                    Att.
                    Guilherme Cortada Dupas

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

                      So you want standard user to be able to do privileged action ?

                      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
                      • guidupasG Offline
                        guidupasG Offline
                        guidupas
                        wrote on last edited by
                        #15

                        I need to be able to create a database from Qt programming. I can access databases but I cant create it directly from the code using firebird.

                        It returns me this error:
                        QSqlError("-902", "Error opening database", "cannot attach to password database")

                        and sometimes this one:
                        QSqlError(”-901”, “Error opening database”, “Can’t access lock files’ directory /tmp/firebird”)

                        I am using this code:
                        @
                        bool DB::conectarServidorFirebird(QSqlDatabase db)
                        {
                        bool retorno = true;

                        db.setHostName("localhost");
                        db.setPassword("gui080381");
                        db.setUserName("sysdba");
                        //db.setPort(3050);
                        
                        if(db.open())
                        {
                            retorno = true;
                        }
                        else
                        {
                            qDebug() << db.lastError();
                        
                            retorno = false;
                        }
                        
                        return retorno;
                        

                        }
                        @

                        Att.
                        Guilherme Cortada Dupas

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

                          Looks more like a firebird setup problem

                          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