FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
12-19-2023 04:51 PM
Hey guys, I am writing an app that looks up information in a sqlite database and forwards it via datalayer to the PLC application running on the core. However I am unsure on how to include the database in the snap. I've tried using the layout feature in the snap.yaml to create a symlink to the database but I am not sure if this is the correctr approach
I am also currently dynamically setting the path in the main program but when I print the path to the log I don't see the snap_data directory being used any thoughts are appreciated.
Solved! Go to Solution.
12-19-2023 07:18 PM
Hello @mvial ,
When you say include the database, do you mean copy an existing database into the application, or connect to an external database?
There are many ways to do this, but I would think you could simply copy the database using the dump plugin. See this example from the SDK.
configs:
plugin: dump
source: ./configs
organize:
'package-assets/*': package-assets/${SNAPCRAFT_PROJECT_NAME}/
This plugin copies the files from the build /configs directory and places the package-assets file within the app folder package-assets/${SNAPCRAFT_PROJECT_NAME}/
12-19-2023 07:49 PM
Thank you @Sgilk I can see that the .db has been included in the snap now the issue I'm having is trying to find the database in relation to where my main.py is executing. I don't really understand how the file structure is arranged within the snap
12-19-2023 08:03 PM - edited 12-19-2023 08:03 PM
The snapcraft stage directory, created on build, is useful for this. It shows the file structure within the application. In this case, I have placed source files in directories of the same name within the snap, using the dump plugin.
12-19-2023 08:03 PM
@Sgilk thanks a bunch, after some guess and check I was able to find where it is in relation to the main.py. I can now stop banging my head against the wall.