LocalDatabase¶
Description¶
The LocalDatabase object is used to store data in a local database using SQLite. The filename is constructed based on the Database.name property or alternatively on the object ID, either specified through the QML object ID or the Object.objectId property.
› Inherits: | Database |
---|
Properties¶
storage¶
This property holds the storage where the database is saved. If left blank a LocalStorage object is used.
› Type: | Storage |
---|---|
› Signal: | storageChanged() |
› Attributes: | Writable, Optional |
Example¶
import InCore.Foundation 2.5
import InCore.Database 2.5
Application {
LocalDatabase {
id: exampleDatabase
DatabaseTable {
id: exampleTable
submitMode: DatabaseTable.SubmitOnCompleteDataset
DateTime { id: date }
Measurement { id: temperature; data: 25 }
}
sqlQueries: [
DatabaseSqlQuery {
forwardOnly: true
query: "SELECT AVG(temperature) AS average
FROM exampleTable"
Polling on results { interval: 10000 }
onResultsChanged: console.log( "average temperature", results[0].average )
onErrorChanged: console.log(errorString)
}
]
}
Timer {
onTriggered: temperature.data += -0.5 + Math.random()
}
}