⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

Newbie in Database

  • 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

  • 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 .

  • 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");
    bool ok = db.open();

  • 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.

  • 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:

Log in to reply