def test_get_user(self): config_string = ''' { "metadb": { "db_username": "******" } } ''' config = json.loads(config_string) username = cf.get_user(config) expected = 'postgraas_user' assert username == expected config_string = ''' { "metadb": { "server": "testserver1", "db_username": "******" } } ''' config = json.loads(config_string) username = cf.get_user(config) expected = 'postgraas_user@testserver1' assert username == expected
def db_connection(config): username = cfg.get_user(config) with psycopg2.connect(database=config['metadb']['db_name'], user=username, password=config['metadb']['db_pwd'], host=config['metadb']['host'], port=config['metadb']['port']) as connection: yield connection
def _get_db_con(): with psycopg2.connect( database=CLUSTER_CONFIG['metadb']['db_name'], user=get_user(CLUSTER_CONFIG), host=CLUSTER_CONFIG['metadb']['host'], port=CLUSTER_CONFIG['metadb']['port'], password=get_password(CLUSTER_CONFIG), ) as con: yield con
def db_connection(config): username = cfg.get_user(config) with psycopg2.connect( database=config['metadb']['db_name'], user=username, password=config['metadb']['db_pwd'], host=config['metadb']['host'], port=config['metadb']['port'] ) as connection: yield connection
def main(): from postgraas_server import postgraas_api config = get_config() db_credentials = { "db_name": config['metadb']['db_name'], "db_username": get_user(config), "db_pwd": get_password(config), "host": config['metadb']['host'], "port": config['metadb']['port'] } wait_for_postgres(db_credentials['db_name'], db_credentials['db_username'], db_credentials['db_pwd'], db_credentials['host'], db_credentials['port']) print("initializing db") init_db(postgraas_api.app)
def main(): from postgraas_server import postgraas_api config = get_config() db_credentials = { "db_name": config['metadb']['db_name'], "db_username": get_user(config), "db_pwd": get_password(config), "host": config['metadb']['host'], "port": config['metadb']['port'] } wait_for_postgres( db_credentials['db_name'], db_credentials['db_username'], db_credentials['db_pwd'], db_credentials['host'], db_credentials['port'] ) print("initializing db") init_db(postgraas_api.app)
def create_db_container(): config = get_config() print(config) db_credentials = { "db_name": config['metadb']['db_name'], "db_username": get_user(config), "db_pwd": get_password(config), "host": config['metadb']['host'], "port": config['metadb']['port'] } if pg.check_container_exists('postgraas_master_db'): print("warning container already exists") postgraas_db = pg.get_container_by_name('postgraas_master_db') db_credentials['container_id'] = postgraas_db.id else: db_credentials['container_id'] = pg.create_postgres_instance( 'postgraas_master_db', db_credentials) return db_credentials
def create_db_container(): config = get_config() print(config) db_credentials = { "db_name": config['metadb']['db_name'], "db_username": get_user(config), "db_pwd": get_password(config), "host": config['metadb']['host'], "port": config['metadb']['port'] } if pg.check_container_exists('postgraas_master_db'): print("warning container already exists") postgraas_db = pg.get_container_by_name('postgraas_master_db') db_credentials['container_id'] = postgraas_db.id else: db_credentials['container_id'] = pg.create_postgres_instance( 'postgraas_master_db', db_credentials ) return db_credentials