Skip to content

Which directory should I put an sqlite3 database? #1776

Answered by freakboy3742
Ivo6 asked this question in Q&A
Discussion options

You must be logged in to vote

Any folder inside your app package will be accessible at runtime, so that's as good a place as any to put content like SQLite databases.

You definitley need to use an absolute path for any reference to that database file - A toga app can't guarantee what the current working directory will be at runtime, as it will vary between platforms (and in the case of mobile deployments, will depend on the specific installation), so relative paths will be ambiguous at best.

To assist with this, the Toga app instance has a paths attribute that contains a useful path roots that you can work off. For example, in your startup() method, you can reference self.paths.app - that will be a Pathlib object prov…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Ivo6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants