[Interest] QSqlDatabase

Karl Ruetz karl.ruetz at ruetzdogz.com
Wed Feb 4 16:16:09 CET 2015


> On Feb 4, 2015, at 7:51 AM, Graham Labdon <Graham.Labdon at avalonsciences.com> wrote:
> 
> Hi
> I am just starting to explore Qt support for databases and have this as a first attempt to open a data base
> 	QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
> 	db.setHostName("bigblue");
> 	db.setDatabaseName("flightdb");
> 	db.setUserName("acarlson");
> 	db.setPassword("1uTbSbAs");
> 	bool ok = db.open();
> 
> When I run this ok is always true, no matter what arguments are passed.
> 
> I would be grateful if someone could explain this
> 
> Thanks
> 

Sqlite has no notion of a user name or password.
If you pass a nonexistent database, sqlite will create it.
I would think the only way QSqlDatabase::open() would return a false would be if the file could not be written; i.e. no read and write privileges for the user running the program.

Karl


More information about the Interest mailing list