Important: Please read the Qt Code of Conduct -

How Can I connect to sqlite database on raspberry pi using lighttpd server

  • Hi all,

    I've installed lighttpd and sqlite on my raspberry pi.
    Now I want to access a database file (sqlite) stored in the Raspberry Pi which I can access using lighttpd server.
    I' ve done the following :

    const QString DRIVER("QSQLITE");
            QSqlDatabase db = QSqlDatabase::addDatabase(DRIVER);
            db.setHostName(""); //Rasberry IP
                qWarning() << "MainWindow::DatabaseConnect - ERROR: " << db.lastError().text();
            qWarning() << "MainWindow::DatabaseConnect - ERROR: no driver " << DRIVER << " available";

    I have no error on compilation, but I can't access to the database on the raspberry.
    Instead, when I launch the app, it create a local database file test.db in the same directory of the .exe .


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Because that's not how it works with SQLite. SQLite is file based so if your really want to access that file on a remote machine, you should mount your remote server folder on your local machine and use that path to access your database. Neither setHostName nor setPort are used by the SQLite backend because they don't make any sense in that context.

  • Thank you @SGaist , I wonder if using php can figure it out. I mean if I use QNetworkAccessManager and connect to a php script placed on my webserver (lighttpd) and in that script I manage the database.

  • Lifetime Qt Champion


    • QNetworkAccessManager and connect to a php script placed on my webserver

    well you can use sqllite as backend if you want.

    you can use QWebChannel to integrate

    but are you sure you want to use sqllite for this ?
    Its really not meant for many concurrent connections.

  • Thx @mrjj , I think I will use php on my webserver. And for the SQlite, I have no choice because it's mandatory for the project that I'm working on.

Log in to reply