Question

I'm developing a GUI Mac OS X application using PyQt+Python which will be distributed through Mac App Store. (Sadly, I have no Objective-C skills for now.)

The app makes use of an sqlite database to save the user inputs, and read from the sqlite database at specific time later. Which means my app requires the sqlite database to be readable/writable.

Before submitting to Mac App Store, right now my app runs well on my MacBook Pro(which I am currently keeping on the same location as the rest of app file dependencies).

Since i know that Apple's sandbox won't allow app read/write data(in my case which means the sqlite database) arbitrary.

My question is:

Since I'm using PyQt & Python to develop the application, where and how can i copy/save the sqlite datebase by code while installing?

If i package my program to a "myapp.app" file(using py2app or cxFreeze utilities), should i put a initial sqlite database in the "Resources" folder of the app bundle? If so, how can i get the sandbox allowed location and copy the database form "Resources" folder to the sandbox allowed location for reading/writing in my python code?

I Search a lot on the web, since i am not a Objective-C developer, i am confused by all the examples which all written in Objective-C. Is this task could be done in Python without calling the API from Cocoa/Objective-C or something?

I'm pretty new to Mac OS X development, so my question maybe foolish, sorry for this. Thank you.

Was it helpful?

Solution

I have fixed this problem by myself.

What i did was place an initial sqlite database in the Resource folder of my app bundle, then copy it by code to a predefined path which was:

os.path.expanduser("~/com.company.AppName/data/Documents/"),

then apple's sandbox will put it in the right folder.

The good news is my app Events got approved by Apple. You may find it on Mac App Store with the name: Events

OTHER TIPS

You use QSettings to manage cross-platform storage of settings for a host of scenarios, including user inputs. Would that help?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top