Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OSX: Where to store SQLite file for application?

My OSX Cocoa application uses SQLite to manage data. When initializing, I need to specify where the database file will be stored.

What is the standard way of handling this?

This database file is required to run (the app will create it if it doesn't exist), and the data should be persisted for ever, even after software updates if possible.

Where should I store it? Application folder? Support Files?

Thanks

like image 542
Nathan H Avatar asked May 31 '11 14:05

Nathan H


People also ask

Where do I put SQLite files?

There is no "standard place" for a sqlite database. The file's location is specified to the library, and may be in your home directory, in the invoking program's folder, or any other place. If it helps, sqlite databases are, by convention, named with a . db file extension.

Where is SQLite database stored on Mac?

SQLite is included in macOS and Mac OS X by default. It is located in the /usr/bin directory and called sqlite3. Using SQLite, users can create file-based databases that can be transported across machines, platforms, etc.

How do I access SQLite database on Mac?

If you are using Linux or a Mac, open a terminal window instead a command prompt. Open a command prompt (cmd.exe) and 'cd' to the folder location of the SQL_SAFI. sqlite database file. run the command 'sqlite3' This should open the SQLite shell and present a screen similar to that below.

Is SQLite stored locally?

SQLite is an offline database that is locally stored in the user's device and we do not have to create any connection to connect to this database.


1 Answers

The convention is to store it in the Application Support folder. i.e. in ~/Library/Application Support/*YourAppName*/database.db

You can find the Application Support that you're searching with

NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
like image 192
gcamp Avatar answered Nov 04 '22 14:11

gcamp