Hello all!
I am trying to create a database directly from my code in Qt, but until now I did not have success, Can anyone help me with some article or some code?
Thanks.
Hello all!
I am trying to create a database directly from my code in Qt, but until now I did not have success, Can anyone help me with some article or some code?
Thanks.
Can you help us with any idea what you have tried and how it "did not have success"?
How are you trying to connect from Qt to Firebird?
The Firebird project offers an ODBC driver, so maybe you can connect to the database using Qt's ODBC driver instead. Make sure you have the Qt database plugins in the right place with respect to your executable, otherwise you won't be able to instantiate the driver.
guidupas (20th February 2015)
I am using the IBase driver and trying to do that with QSqlDriver, but it does not have the statement to create database.
I need to do it directly from the Qt code, like is done with manager softwares but the connection to database returns an error if I dont select a database to connect.
"Firebird doesn't provide a way to create database using SQL. You need to either use the Services API, or external tool. As API for database creation is often not available in libraries, you can call Firebird's isql tool to do it for you..."
http://www.firebirdfaq.org/faq67/
guidupas (19th February 2015)
Thanks for the reply ChrisW67, it helped a lot. But I am trying to figure out how to execute to isql via stdin. Could you help me with this doubt?
Use QProcess to run isql from your application. You can either use isql -i to read/execute SQL commands from a file or you can use QProcess and write commands to the stdin of the running QProcess using QProcess:write().
guidupas (20th February 2015)
Thanks jthomps, I am going to try it.
Thanks to d_stranz too. I will take a look at the firebird ODBC driver too.
One comment regarding your approach. Is it reasonable to expect your users to have isql installed or are you planning on shipping isql somewhere in your bundle?
Another thing you could consider is to ship an empty firebird database (created with isql but not objects created) with your app and copy that empty database the first time you start your app. You should be able to then create any tables, indexes, or views needed by your app, etc.
Good luck.
Bookmarks