I am trying to create a database locally (right now on desktop and later to a phone)
Using this website: https://mimecar.gitbook.io/qt-course...chapter-05-s01
I understand the SQL statements create table, INSERT, FOR loop etc....
My issue is I cant see where the database is being created. I need a physical DB on my devise that I can write too....Eventually using those records to update a database on my server.
Right now I just need help:
1. creating a Database IF NOT THERE and creating it in a specific location
2. The ability to write records to that database
3. And view the database records
Can anyone please help....
// SNIP
import QtQuick.LocalStorage 2.0
// SNIP
var db = LocalStorage.openDatabaseSync(weatherRecorder_db, "1.0", "StorageDatabase", 1000000);
db.transaction(
function(tx) {
// Create the database if it doesn't already exist
tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)');
// Add (another) greeting row
tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
// Show all added greetings
var rs = tx.executeSql('SELECT * FROM Greeting');
var r = ""
for(var i = 0; i < rs.rows.length; i++) {
r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n"
}
text = r
console.log(text);
}
)
// SNIP
import QtQuick.LocalStorage 2.0
// SNIP
var db = LocalStorage.openDatabaseSync(weatherRecorder_db, "1.0", "StorageDatabase", 1000000);
db.transaction(
function(tx) {
// Create the database if it doesn't already exist
tx.executeSql('CREATE TABLE IF NOT EXISTS Greeting(salutation TEXT, salutee TEXT)');
// Add (another) greeting row
tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
// Show all added greetings
var rs = tx.executeSql('SELECT * FROM Greeting');
var r = ""
for(var i = 0; i < rs.rows.length; i++) {
r += rs.rows.item(i).salutation + ", " + rs.rows.item(i).salutee + "\n"
}
text = r
console.log(text);
}
)
To copy to clipboard, switch view to plain text mode
Bookmarks