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");
db.setHostName("????");
db.setDatabaseName("???");
db.setUserName("");
db.setPassword("");
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.