Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Can't open a mysql-db on pi

Can't open a mysql-db on pi

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
5 Posts 2 Posters 946 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.
  • M Offline
    M Offline
    Michl
    wrote on 8 Apr 2016, 07:39 last edited by
    #1

    I'm trying to open and access a mysql-db on a pi. I've built a cross development environment and it works fine.
    The problem now is this snippet:

    dbAbholer.addDatabase("QMYSQL");
    dbAbholer.setHostName("localhost");
    dbAbholer.setDatabaseName("test");
    dbAbholer.setUserName("user");
    dbAbholer.setPassword("password");
    bool ret = dbAbholer.open();
    qDebug() << ret;
    qDebug() << "---------------------------";
    qDebug() << dbAbholer.lastError().text();
    qDebug() << "---------------------------";
    qDebug() << qApp->libraryPaths();
    qDebug() << QSqlDatabase::drivers();

    The output is:

    Unable to query physical screen size, defaulting to 100 dpi.
    To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).
    false

    "Driver not loaded Driver not loaded"

    ("/usr/local/Qt-5.5.1-raspberry/plugins", "/home/pi")
    ("QSQLITE", "QSQLITE2", "QMYSQL", "QMYSQL3", "QTDS", "QTDS7")

    The access to the db should work, i've tried it via mysql-command line.

    Whats wrong with my code?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Michl
      wrote on 8 Apr 2016, 13:55 last edited by
      #2

      I tried a lot of things and find out the solution:

      False:
      QSqlDatabase dbAbholer;
      dbAbholer.addDatabase("QMYSQL");

      Right:
      QSqlDatabase dbAbholer = QSqlDatabase::addDatabase("QMYSQL");

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 8 Apr 2016, 22:33 last edited by
        #3

        Hi and welcome to devnet,

        addDatabase is a static method that's why it didn't work. However, didn't you got a compiler warning when doing that ?

        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
        • M Offline
          M Offline
          Michl
          wrote on 9 Apr 2016, 10:14 last edited by
          #4

          Thanks for your response. No i did not recognize any error while compiling.
          Well my development environment is: Windows PC with a virtual machine running ubuntu. The target is a raspberry. So its a cross-environment. Perhaps this is the reason?
          BTW, it tooks a very long time to build this environment with all drivers for sql, touch etc. Especially the touch in combination with eglfs was very hard (one need tslib from other sources etc.)

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 9 Apr 2016, 19:59 last edited by
            #5

            Not an error, a warning.

            Embedded development is rarely a piece of cake ;)

            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

            1/5

            8 Apr 2016, 07:39

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved