Congratulations to our 2022 Qt Champions!

Location of SQLite database

  • Is there a way to specify the SQLite database that LocalStorage.openDatabaseSync uses? There is a way to specify the offline storage path, QQmlEngine::offlineStoragePath(), but don't see how to set the file name of the database.

  • Qt Champions 2017

    I don't think anything exist like this. We tried earlier and did not go anywhere. Enjoy the same.

  • Essentially I need to use SQL as a conduit between Python and QML. I want to be able to write temperature data to a previously created SQL database from a loop on a timer in Python and then display the same data in my QML app? My QML app has multiple screens and this data would only be displayed when a specific screen is visible. Other QML screens will have an interface to write data to the SQL database and then be read and used in Python. Do you have any suggestions on what I could try and use? I had this kind of working using offLineStorage, but then ran into the issue of not being able to set the database name to be the same in Python and QML. This is on a Raspberry Pi using the GPIO pins to retrieve data from sensors.

  • @JasonS I developed this way can this help you?

    import m7.Database 1.1

    Database {

    id: database
    driver: Database.SQLITE //Enum  define driver to  sql
    hostName: "localhost" // or ip
    nameBase:  "/home/name.db"
    Component.onCompleted: {
        var isOpen =
            console.log("Database is open!")
            //start query
        id: result
        database: database
        sqlQuery: "SELECT * FROM my_table"
            //get query Columns
            var column1 = value("column 1 name")
            var column2 = value("column 2 name")
            //etc ...
            //call next row 
            console.log("End process query")
            //close database
    //function salve datas
    function salveDatas(){
        var isOpen =
            console.log("not isOpen");
            return false;
            var st =  database.prepareStatement("INSERT INTO my_table (column_name) VALUES (?)")
            //salva o script database
            var status = st.executeUpdate()
            console.log("Error: "+e)
        return status


  • Looks promising. What is m7? I did a quick search and didn't get any hits. I found something similar to this on YouTube ( and this method uses oviont which I haven't heard of before either.

Log in to reply