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
Solution 1:
I've found a solution by dividing my application data into two categories:
- stateful data
- dynamic data
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.
Post a Comment for "How To Preserve A Sqlite Database From Being Reverted After Deploying To Openshift?"