How to preserve a SQLite database from being reverted after deploying to OpenShift?

I ported a Python Twisted application to OpenShift, which stores its data to a SQLite database. After putting database file to the git repo data/ directory (during the first deploy) I had no issues, but the database was simply resetted at the second deploy.

I searched for a proper solution to this weird behavior (considering that the database was under versioning) and then I found the answer in the OpenShift Knowledge Base:

The short solution to this issue is to store your SQLite database <strong>one level up from your git repository in the ‘data’ directory</strong>.

Now my question is what happens when I move the database to this directory? Have I to move or copy the data directory's content? And this data will be preserver from deploy to deploy?

I tried to move the database from repo/data to data/ directory but the application cannot access this upper level directory. I'm looking for the best solution to this problem.


I've found a solution by dividing my application data into two categories:

    <li>stateful data</li> <li>dynamic data</li> </ul>

    I left the stateful information in the repo/data directory and I moved permanently the changing data to the upper level data/ directory. Making this change I am able to maintain the stateful_data under version control in my git repo accessing them through:

    __location__ = os.path.realpath(os.path.join(os.getcwd(), os.path.dirname(__file__))) static_data_folder = __location__ + '/data/'

    The dynamically generated data is then moved to $OPENSHIFT_DATA_DIR which is NOT under version control and corresponds to the upper level directory of my app-root. I changed my getter in my singleton Configuration module to return this mutable data folder:

    self.mutable_data_path = os.environ['OPENSHIFT_DATA_DIR'] + "mutable_data_subdir/"

    I'm testing this configuration right now but it seems to work like a charm.


  • Test version of api.ai Google Action while I have a live version?
  • IL constrained call
  • Eclipse unable to get info on the interpreter in virtual environment
  • Core Data Model Design - Changing “Live” Objects also Changes Saved Objects
  • Using Google Api: Speech To Text on PC Version
  • Tracking screen recorder in windows app
  • How to resolve dependencies from one gradle project to another gradle project in my Eclipse workspac
  • EF 4.1 DBContext AutoDetectChangesEnabled
  • PHP multiple file uploads
  • ImportError: cannot import name Pubnub
  • Javascript/Jquery runs fast in desktop browsers, but slow in mobile/smartphone browsers…should I spl
  • Compare struct to a constant in C
  • Wrong labels when plotting a time series pandas dataframe with matplotlib
  • In matplotlib, how do you change the fontsize of a single figure?
  • Spring: No transaction manager has been configured
  • accepts_nested_attributes_for practical form use for in Rails 3
  • How do I signal completion of my dataflow?
  • Object and struct member access and address offset calculation
  • Convert Type Decimal to Hex (string) in .NET 3.5
  • Android application: how to use the camera and grab the image bytes?
  • How to add git credentials to the build so it would be able to be used within a shell code?
  • Parsing a CSV string while ignoring commas inside the individual columns
  • Avoid links criss cross / overlap in d3.js using force layout
  • How do I change content of ComboFieldEditor?
  • QLineEdit password safety
  • Display issues when we change from one jquery mobile page to another in firefox
  • Different response to non-authenticated users and AJAX calls
  • Can Jackson SerializationFeature be overridden per field or class?
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Redux, normalised entities and lodash merge
  • Weird JavaScript statement, what does it mean?
  • Do I've to free mysql result after storing it?
  • Jquery - Jquery Wysiwyg return html as a string
  • Arrays break string types in Julia
  • Data Validation Drop Down Box Arrow Disappearing
  • Android Studio and gradle
  • SQL merge duplicate rows and join values that are different
  • WPF Applying a trigger on binding failure
  • Java static initializers and reflection
  • How to get NHibernate ISession to cache entity not retrieved by primary key