Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved start with the QtSQL module

    General and Desktop
    6
    18
    1683
    Loading More Posts
    • 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
      EL-jos last edited by

      Hi everyone, I'm a beginner in Qt but I'd like to use the QtSQL module but I don't understand anything about the directions given by the documentation.
      Can anyone tell me what I need to do to use the QtSQL module, what do I need to install on my computer to use QtSQL?

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        What version of Qt ?
        What OS ?
        How did you install Qt ?

        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 Reply Quote 0
        • E
          EL-jos last edited by

          I use Qt version 5.10
          I am on windows 10
          I had downloaded Qt Creator from Qt's official website.

          1 Reply Last reply Reply Quote 0
          • Christian Ehrlicher
            Christian Ehrlicher Lifetime Qt Champion last edited by

            So the QtSql module is already available and you can just start using it like explained here: https://doc.qt.io/qt-5/qtsql-index.html

            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 Reply Quote 2
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              What kind of database do you plan to use ?

              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 Reply Quote 0
              • E
                EL-jos last edited by

                Hi
                Sorry for the delay in my answer.

                actually I want to use MYSQL

                1 Reply Last reply Reply Quote 0
                • SGaist
                  SGaist Lifetime Qt Champion last edited by

                  Do you have MySQL installed on your machine ?

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

                  E 1 Reply Last reply Reply Quote 0
                  • 1
                    123456789 last edited by

                    @SGaist comigo não resultou

                    1 Reply Last reply Reply Quote 0
                    • SGaist
                      SGaist Lifetime Qt Champion last edited by

                      @123456789 said in start with the QtSQL module:

                      comigo não resultou

                      How is it related to the question at hand ?

                      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 Reply Quote 0
                      • E
                        EL-jos @SGaist last edited by

                        @SGaist since I'm also a webmaster so I use phpMyAdmin for the MYSQL database.

                        1 Reply Last reply Reply Quote 0
                        • 1
                          123456789 last edited by

                          @SGaist not result
                          yes
                          not result your solution

                          1 Reply Last reply Reply Quote 0
                          • KillerSmath
                            KillerSmath last edited by KillerSmath

                            @123456789
                            Get access of all sql modules using QT += sql in .pro file of your project.

                            You can create a database object to create a connection with your database using QsqlDatabase Class

                            http://doc.qt.io/qt-5/sql-connecting.html

                            With a created database object, you can use QSqlQuery to insert, update, remove or recover information of your database

                            http://doc.qt.io/qt-5/sql-sqlstatements.html

                            @Computer Science Student - Brazil
                            Web Developer and Researcher
                            “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

                            1 Reply Last reply Reply Quote 0
                            • 1
                              123456789 last edited by

                              not result

                              1 Reply Last reply Reply Quote 0
                              • mrjj
                                mrjj Lifetime Qt Champion last edited by

                                Hi
                                Can you try this demo project.
                                It runs for me and if yours still fail, something is wrong with your Qt install.
                                https://www.dropbox.com/s/uo43f7sbiwcjazv/mySqlite.zip?dl=0

                                output:

                                create table: true

                                "Young"
                                "Holand"
                                "Gordon"
                                "Robitaille"
                                "Papadopoulos"

                                1 Reply Last reply Reply Quote 0
                                • E
                                  EL-jos last edited by

                                  Hi, here's my source code:

                                  QSqlDatabase m_database = QSqlDatabase::addDatabase("QMYSQL");
                                  m_database.setDatabaseName("127.0.0.1");
                                   m_database.setPort(3306);
                                  m_database.setUserName("root");
                                  foreach(QString pilote, m_database.drivers())
                                      qDebug()<< "Pilote: " << pilote;
                                  if(m_database.open())
                                      qDebug() << "Connexion réussie.";
                                  

                                  and here's the result:
                                  QSqlDatabase: QMYSQL driver not loaded

                                  QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7

                                  Pilote: "QSQLITE"

                                  Pilote: "QMYSQL"

                                  Pilote: "QMYSQL3"

                                  Pilote: "QODBC"

                                  Pilote: "QODBC3"

                                  Pilote: "QPSQL"

                                  Pilote: "QPSQL7"

                                  1 Reply Last reply Reply Quote 1
                                  • SGaist
                                    SGaist Lifetime Qt Champion last edited by

                                    I guess you are hitting the usual problem: do you have the MySQL client libraries that are accessible by your application ?

                                    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 Reply Quote 1
                                    • E
                                      EL-jos last edited by

                                      I don't know what a MySQL client library is and how to get it and what its importance?
                                      if it is necessary to make simple I know nothing in module QtSQL
                                      so if you can really help me use the QtSQL module, if there are things to download, you can tell me by posting the download link.

                                      1 Reply Last reply Reply Quote 0
                                      • SGaist
                                        SGaist Lifetime Qt Champion last edited by

                                        The MySQL issue already triggered numerous threads on this forum, you should search for them.

                                        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 Reply Quote 0
                                        • First post
                                          Last post