Location of SQLite database
-
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 = database.open() if(isOpen){ console.log("Database is open!") //start query result.startQuery() } } ResultSet{ id: result database: database sqlQuery: "SELECT * FROM my_table" //Slot onResultQuery:{ //get query Columns var column1 = value("column 1 name") var column2 = value("column 2 name") //etc ... //call next row next() } onEndQuery:{ console.log("End process query") //close database database.close() } } //function salve datas function salveDatas(){ var isOpen = database.open() if(!isOpen){ console.log("not isOpen"); return false; } try{ var st = database.prepareStatement("INSERT INTO my_table (column_name) VALUES (?)") st.insert(0,'data') //salva o script database var status = st.executeUpdate() }catch(e){ console.log("Error: "+e) }finally{ database.close() } 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 (https://www.youtube.com/watch?v=k_mKZ7xz-uA&list=FLwjNCTYuaSVzqAgz2AJ04sg&index=1) and this method uses oviont which I haven't heard of before either.