hello,I create an app that use for save data,but i have an problom!I want when my app execute on other computer for the frist time,automatically create databse on that comuter if not exist! please help me!!
hello,I create an app that use for save data,but i have an problom!I want when my app execute on other computer for the frist time,automatically create databse on that comuter if not exist! please help me!!
I don't think this is qt relevant question. check the format of the query regarding to the DBMS you are using, CREATE TABLE IF NOT EXISTS is for mysql I guess.
my connecting file cantains this code:
Qt Code:
bool createConnection() { db.setHostName("localhost"); db.setDatabaseName("sa2"); db.setUserName("root"); db.setPassword(""); if (!db.open()) { db.lastError().text()); return false; } return true; }To copy to clipboard, switch view to plain text mode
I have only one problem and thats is I forced to create db manually when I execute my app another computer.I want my db create automatically!
There should of course be api functions relevant to db_create or db_query and alike. Go through my sql c api functions and execute either the create function or the query function and write the query i mentioned above as a parameter.
You will need a MySql privileged user account, connect to the mysql system database as that user, execute a "create database" statement, statements to create tables, and statements to create users and/or grant privileges. Then disconnect as the privileged user, connect as the usual minimally privileged user to continue using your new database.
Bookmarks