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. Newbie in Database
Forum Updated to NodeBB v4.3 + New Features

Newbie in Database

Scheduled Pinned Locked Moved General and Desktop
5 Posts 4 Posters 1.1k 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.
  • S Offline
    S Offline
    SahamGhazavi
    wrote on last edited by
    #1

    Hi all

    It is my first trying to program in Qt using database on Mac.What to be the first steps to setup my DB and other settings?
    I have MySQL Workbench installed and created one schema called test and one table under it called People.

    Thank you in advance

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on last edited by
      #2

      Hi maybe "this":http://qt-project.org/doc/qt-5/sql-connecting.html could be a good start point. Also take a look to "examples":http://qt-project.org/doc/qt-5/examples-sql.html .

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SahamGhazavi
        wrote on last edited by
        #3

        Thank you but what go for hostname and db name on mac?
        I assume hostname would be localhost. Is dbname the same az schema name?

        db.lasterror shows driver is not installed

        @
        QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL");
        db.setHostName("????");
        db.setDatabaseName("???");
        db.setUserName("");
        db.setPassword("");
        bool ok = db.open();
        @

        1 Reply Last reply
        0
        • B Offline
          B Offline
          BlackStar
          wrote on last edited by
          #4

          I could help you but i never used a Mac, for the hostname yes localhost if your computer running a program that make it run like a server, like wampserver in Windows, for the databasename it is the name of the database, i assume that you opened MySql in the dos prompt, and you tiped :
          CREATE DATABASE test, after this there will be a database by the name of test, where you put your tables.
          To acces to this database you use the method QSqlDatabase::setDatabasename, and for the username and the password you set the username and the password you used to create this database, if you ve just started working on MySql, then it is ROOT and the password is an empty string.

          For the error you should check for how to install the MySql Driver on your mac.

          1 Reply Last reply
          0
          • C Offline
            C Offline
            clochydd
            wrote on last edited by
            #5

            Hi, yes, localhost is correct if you are working with a local database.
            The name of your database is what you used in:
            CREATE DATABASE databasename
            and not the same as a schema name.
            You may find the name by typing:
            SHOW DATABASES

            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