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. failing to make the code to connect to a database in PyQt5
Forum Updated to NodeBB v4.3 + New Features

failing to make the code to connect to a database in PyQt5

Scheduled Pinned Locked Moved Solved Qt for Python
14 Posts 3 Posters 1.5k 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.
  • SGaistS SGaist

    Hi and welcome to devnet,

    Your addDatabase call is invalid.

    If your version of PyQt is recent enough your likely do not have the MySQL backend because it's currently not prebuilt anymore due to a change of licensing from Oracle.

    A Offline
    A Offline
    adrian88888888
    wrote on last edited by
    #4

    @SGaist thanks!, what are my options then? should i go to PyQy4?

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

      Which version are you currently using ?

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

      A 1 Reply Last reply
      0
      • SGaistS SGaist

        Which version are you currently using ?

        A Offline
        A Offline
        adrian88888888
        wrote on last edited by
        #6

        @SGaist I don't know how to get the exact versions but they are:
        -PySide2
        -PyQt5
        -MySQL 8.0

        .........................................................................................................................................................

        @JonB instead of DataBase = db.open()maybe it is just db.open()?, i put that because of something in the documentation, i suspect that's wrong in some way, in my code there's nothing called DataBase

        but MyTree.setModel(.model) exist in the code, i created the treeView

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

          How did you install these packages ?

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

          A 1 Reply Last reply
          0
          • SGaistS SGaist

            How did you install these packages ?

            A Offline
            A Offline
            adrian88888888
            wrote on last edited by
            #8

            @SGaist
            for being new i can reply every 10 minutes sorry
            1-pip install PySide2
            2-I did not install PyQt5(i guess it comes somehow inside pip install PySide2)
            3-MySQL from the page of the comunity sever: link text

            in the documentation says that is compatible, in this table link text, it says in the 3rd row: MySQL or MariaDB (version 5.0 and above)

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

              Then pip can give you the version you installed.

              PyQt5 and PySide2 are two different projects that are unrelated.

              What you can do is install a version that uses a version of Qt that is less recent so you'll have the plugin already available.

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

              A 1 Reply Last reply
              0
              • SGaistS SGaist

                Then pip can give you the version you installed.

                PyQt5 and PySide2 are two different projects that are unrelated.

                What you can do is install a version that uses a version of Qt that is less recent so you'll have the plugin already available.

                A Offline
                A Offline
                adrian88888888
                wrote on last edited by adrian88888888
                #10

                @SGaist the pip showed me that the version of Pyside2 is 5.15.0

                ohh i remember now, i installed "pip install PyQt5", im newbie so i hardly understand what i'm doing, the version of PyQt5 is 5.13.2

                so you mean that i should uninstall PyQt5 and put an older version like PyQt4? or i should have an older version of Pyside2?

                what gets me really lost is that the documentation says that is compatible here, in the 3rd row of the table

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

                  Compatible it is. What is happening is that Oracle changed their licensing therefore the plugin is currently not provided pre-built anymore.

                  So, did you try your code with both libraries ?

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

                  A 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Compatible it is. What is happening is that Oracle changed their licensing therefore the plugin is currently not provided pre-built anymore.

                    So, did you try your code with both libraries ?

                    A Offline
                    A Offline
                    adrian88888888
                    wrote on last edited by
                    #12

                    @SGaist i changed to another database (sqlite) and it worked!, thanks a lot, i wouldn't figured it out on my own

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

                      If you need a remote database system PostgreSQL is also a very good solution.

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

                      A 1 Reply Last reply
                      0
                      • SGaistS SGaist

                        If you need a remote database system PostgreSQL is also a very good solution.

                        A Offline
                        A Offline
                        adrian88888888
                        wrote on last edited by
                        #14

                        @SGaist yes i imagine that there's other solutions, but i'm going basic for now

                        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