def __init__(self, rdbms=None, address=None, port=None, dbname=None, username=None, password=''): if not rdbms: rdbms = 'postgres' if rdbms == 'postgres': if not address: address = os.environ.get('PGHOST', '') if not dbname: dbname = os.environ.get('PGDATABASE', 'stoq') if not username: username = os.environ.get('PGUSER', get_username()) if not port: port = os.environ.get('PGPORT', 5432) self.rdbms = rdbms self.address = address self.port = port self.dbname = dbname self.username = username self.password = password self.first = True
def _provide_database_settings(): db_settings.username = os.environ.get(u'STOQLIB_TEST_USERNAME', get_username()) db_settings.hostname = os.environ.get(u'PGHOST', u'localhost') db_settings.port = int(os.environ.get(u'PGPORT', u'5432')) db_settings.dbname = os.environ.get(u'STOQLIB_TEST_DBNAME', u'%s_test' % db_settings.username) db_settings.password = u''
def provide_database_settings(dbname=None, address=None, port=None, username=None, password=None, createdb=True): """ Provide database settings. :param dbname: :param address: :param port: :param username: :param password: :param create: Create a new empty database if one is missing """ if not username: username = get_username() if not dbname: dbname = username + u'_test' if not address: address = os.environ.get(u'PGHOST', u'') if not port: port = os.environ.get(u'PGPORT', u'5432') if not password: password = u"" # Remove all old utilities pointing to the previous database. utilities.clean() provide_utility(ISystemNotifier, test_system_notifier, replace=True) _provide_application_descriptions() _provide_domain_slave_mapper() _provide_app_info() db_settings.address = address db_settings.port = port db_settings.dbname = dbname db_settings.username = username db_settings.password = password rv = False if createdb or not db_settings.database_exists(dbname): db_settings.clean_database(dbname, force=True) rv = True return rv
def provide_database_settings(dbname=None, address=None, port=None, username=None, password=None, create=True): """ Provide database settings. :param dbname: :param address: :param port: :param username: :param password: :param create: Create a new empty database if one is missing """ if not username: username = get_username() if not dbname: dbname = username + u'_test' if not address: address = os.environ.get(u'PGHOST', u'') if not port: port = os.environ.get(u'PGPORT', u'5432') if not password: password = u"" # Remove all old utilities pointing to the previous database. utilities.clean() provide_utility(ISystemNotifier, test_system_notifier, replace=True) _provide_application_descriptions() _provide_domain_slave_mapper() _provide_app_info() db_settings.address = address db_settings.port = port db_settings.dbname = dbname db_settings.username = username db_settings.password = password rv = False if create or not db_settings.database_exists(dbname): db_settings.clean_database(dbname, force=True) rv = True return rv