Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/changes/unreleased.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
# Unreleased

## Features
- #55 Added publicly callable function finding the database id from its name.
23 changes: 20 additions & 3 deletions exasol/saas/client/api_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,7 @@ def _get_database_id(
database_name: str,
) -> str:
"""
Finds the database id, given an optional database name. If the name is not
provided returns an id of any non-deleted database. The latter option may be
useful for testing.
Finds the database id, given the database name.
"""
dbs = list_databases.sync(account_id, client=client)
dbs = list(filter(lambda db: (db.name == database_name) and # type: ignore
Expand All @@ -96,6 +94,25 @@ def _get_database_id(
return dbs[0].id


def get_database_id(
host: str,
account_id: str,
pat: str,
database_name: str,
) -> str:
"""
Finds the database id, given the database name.

Args:
host: SaaS service URL.
account_id: User account ID
pat: Personal Access Token.
database_name: Database name.
"""
with create_saas_client(host, pat) as client:
return _get_database_id(account_id, client, database_name)


def get_connection_params(
host: str,
account_id: str,
Expand Down