(contribution of Bernardo Heynemann heynemann@gmail.com)
Add support to create a in-place config for cases that you would
like to configure simple-db-migrate programatically.
Add the following code to core.py.
class InPlaceConfig(object):
def __init__(self, db_host, db_user, db_password, db_name, migrations_dir, db_version_table="__db_version__"):
self.__config = {
"db_host":db_host,
"db_user":db_user,
"db_password":db_password,
"db_name":db_name,
"db_version_table":db_version_table,
"migrations_dir":migrations_dir
}
def get(self, config_key):
try:
return self.__config[config_key]
except KeyError, e:
raise Exception("invalid configuration key ('%s')" % config_key)
def put(self, config_key, config_value):
if config_key in self.__config:
raise Exception("the configuration key '%s' already exists and you cannot override any configuration" % config_key)
self.__config[config_key] = config_value