Database location changes from runtime to compiled app

I am building an OSX desktop app.

When I ‘run’ an application with the ability to debug, I get a database location of: /users/Phil/Library/Containers/com.etc/Data/Library/Application Support/database.sqlite
When I compile and run it, I get a database location of: users/Phil/Library/Application Support/database.sqlite

Can anyone explain why this is so?

I am confused as to why this is a good idea. When I make changes to the database, I need to synchronise the two and make sure I don’t get it the wrong way around.

Thanks for your insights


What is the code you use to open the database? What path are you using?

// create database if not existing

MyDBFile = SpecialFolder.ApplicationData.Child(“HH.sqlite”)
If MyDBFile <> Nil Then
MyDatabase = New SQLiteDatabase
MyDatabase.DatabaseFile = MyDBFile
If MyDatabase.CreateDatabaseFile() Then
If MyDatabase.Connect() Then
Return True
Return False
End If
Return False
End If
End If

Our apps connect to different databases depending on the stage code and if its on the cloud or local. Best thing we’ve found was to have a configuration file that has all your information for database connections in it and have your application read that file. Do make sure you encrypt the file contents though.

Wait a second, when you debug your application is sandboxed and when you use the built version it’s not?
That is not normal behavior. Are you using AppWrapper or anything to automate build steps? Is it possible you’re sandboxing on debug instead of release?

Also you need to be using a child folder of your own within Application Support. Do not store your database file directly in SpecialFolder.ApplicationData, you need to use SpecialFolder.ApplicationData.Child("").Child("database.sqlite").

Alternatively, for easy cross-platform ready handling of that process you can use the TPSF module to handle that:

Thanks Tim.
I am still beginning to understand the processes involved here. I am using AppWrapper to automate build steps, but still coming to terms with what is actually going on. I will make the changes you suggest and take a look at the URL you mention.