[Interest] localstorage metadata via sqlite_master
Jesus Fernandez
jesus.fernandez at qt.io
Wed May 11 10:26:19 CEST 2016
On Tuesday, May 10, 2016 02:46:16 PM Kevin Mcintyre wrote:
> I see that sqlite has table information via sqlite_master
>
> http://www.sqlite.org/faq.html#q7
>
> Is this table available in Qt localstorage?
Hi!
I modified the sample from the documentation:
To get the info you should query this as a table, for example to show current tables in the
database:
import QtQuick 2.5
import QtQuick.Window 2.2
import QtQuick.LocalStorage 2.0
Window {
visible: true
Text {
text: "?"
anchors.horizontalCenter: /parent/.horizontalCenter
function /findGreetings/() {
var /db/ = LocalStorage.openDatabaseSync("QQmlExampleDB",
"1.0",
"The Example QML SQL!",
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)');
// Show all tables
var /rs/ = /tx/.executeSql('SELECT name FROM sqlite_master '
+ 'WHERE type="table"');
var /r/ = ""
for(var /i/ = 0; /i/ < /rs/.rows.length; /i/++) {
/r/ += /rs/.rows.item(/i/).name + "\n"
}
/text/ = /r/
}
)
}
Component.onCompleted: /findGreetings/()
}
}
--
Best regards,
Jesus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20160511/f2f623ed/attachment.html>
More information about the Interest
mailing list