A skill template that uses SQLite


#1

Hello!

This is a skill template which can be used to keep local data using SQLite. Feel free to add to your Skills as long as there is credit.
An example would be a database of audiobooks for a local reading list.
Here is the link to the Github repo.


Sleep-tracker-skill
#2

Hey this is great, thanks so much for sharing it! I think lots of people are going to find this useful for new Skills.

One small suggestion would be to use self.file_system.path that is available in the MycroftSkill class as the directory to store the database. Would need to pass it in when creating the new instance of the BufordSQLite class.

The current version works on a desktop environment, but not on a Mark 1 for example. The intention behind self.file_system is to provide a consistent skill-specific namespace. So regardless of where Mycroft is installed, it will always save the database at ~/.mycroft/skills/SQLiteDemoSkill/


#3

Thanks!
Not sure why it did not work on the Mark 1 (I don’t have it at the moment) but for the desktop version, it saved the sqlite file to the mycroft-core directory.
I might also test this on Picroft (since I just got my pi) before doing something to be sure.


#4

On Mark1’s the mycroft-core directory is located at /opt/venvs/mycroft-core so the user doesn’t have adequate permissions.

I imagine it will work on Picroft as mycroft-core is stored in /home/pi/mycroft-core, however it’s still not recommended as mycroft-core can be run from any number of places. The file_system method just provides a much cleaner way to handle these that you know will be expected and respected in future releases.


#5

Updated the BufordSQLclass to accept a path, which can be defined on the skill constructor.
The self.file_system.path did work. On Picroft the buford.db file now saves to /home/pi/.mycroft/skills/SQLiteDemoSkill.

Can anyone with a Mark 1 test it just in case?


#6

Working great on a Mark 1 for me :slight_smile: