In-place config support
Reported by Guilherme Chapiewski | June 17th, 2009 @ 12:05 AM | in v1.2.8
(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
Comments and changes to this ticket
-
Guilherme Chapiewski June 17th, 2009 @ 01:27 AM
- State changed from new to resolved
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
simple-db-migrate is a database migration tool inpired on Rails migrations. For more info check the project website: http://guilhermechapiewski.github.com/simple-db-migrate/