0

I'm trying to write a desktop widget (plasmoid) for KDE Plasma. I've got a nice sqlite database I've put together. I discovered the QML LocalStorage database system today, but in my opinion it's not well documented.

My main question is... can I add my database to this system somehow?

It'd be great if I could use this built-in sqlite client system, because it means I could distribute my little widget without the need for any kind of C++ backend (which would need compiling; if it I could do it all in Javascript, I'd be set.)

Dito
  • 182
  • 3
  • 12
  • Do you want to import your .db in the LocalStorage? – eyllanesc Aug 04 '18 at 04:00
  • The database file, created by `LocalStorage` is stored in [QQmlEngine::offlineStoragePath()](http://doc.qt.io/qt-5/qqmlengine.html#offlineStoragePath-prop). But the file name is a hash of db name. I would create a new database and then replace created file with my own db file with the same name. – folibis Aug 04 '18 at 09:42
  • @eyllanesc: It's for a plasmoid recreating the old `fortune` program. I've got about 8,000 rows I'd have to insert.Feels kind of guilty storing that nonsense on someone's system. I'd rather keep it self-contained. (Plus I wouldn't need any kind of install/uninstall routine.) – Dito Aug 04 '18 at 09:47
  • I found "sql.js", where someone's compacted sqlite into a single Javscript file. In theory, I could use that, but I can't seem to get the plasmoid to pick up and use the external JS library. – Dito Aug 04 '18 at 09:52
  • @Dito I do not use plasmoid, I do not know the fortune program so I ask you to please consider it and explain my question in more detail – eyllanesc Aug 04 '18 at 09:56
  • @eyllanesc `fortune` was an old Unix program. When you'd log in for the first time each day, you'd get a brief message or quotation. I'm making a desktop widget that will put out a random message. I have a sqlite database of about 7000 quotations from 19 sources. I want to select one and display it. Plasmoid widgets are QML + Javascript. If you want/need to use C++, you need to compile the DB module. If you can do it in pure QML/JS, nothing to compile and much easier to install for the user. (It can be automated.) – Dito Aug 04 '18 at 11:03
  • @Dito So in conclusion, you want to use the .db already existing from QML, is my conclusion correct? – eyllanesc Aug 04 '18 at 11:06
  • @eyllanesc: No, the database is sqlite3. I want to query it from QML. – Dito Aug 04 '18 at 11:41
  • @Dito It's the same as I said :) – eyllanesc Aug 04 '18 at 11:41
  • @eyllanesc: Okay, then - yes - I'd like to move my data from the sqlite file and place it in `Local Storage`. Can I do that? How? – Dito Aug 04 '18 at 11:52
  • Possible duplicate of [Import an External SQLite database to my project](https://stackoverflow.com/questions/36936420/import-an-external-sqlite-database-to-my-project) – eyllanesc Aug 04 '18 at 12:17

0 Answers0