def graph_db(localhost): from polyglotdb.client.client import PGDBClient, ClientError client = PGDBClient(localhost) dbs = client.list_databases() for d in dbs: if 'test' in d: client.delete_database(d) client.create_database('main_test_database') ports = client.get_ports('main_test_database') ports['data_dir'] = client.get_directory('main_test_database') ports['host'] = 'localhost' client.start_database('main_test_database') return ports
def graph_db(localhost, auth_token): from polyglotdb.client.client import PGDBClient, ClientError client = PGDBClient(localhost, token=auth_token) dbs = client.list_databases() print(dbs) for d in dbs: if d['name'] == 'main_test_database': client.delete_database(d['name']) client.create_database('main_test_database') ports = client.get_ports('main_test_database') ports['data_dir'] = client.get_directory('main_test_database') ports['host'] = 'localhost' client.start_database('main_test_database') return ports