Skip to content

Commit 8831dfd

Browse files
authored
#55 Added publicly callable get_database_id function (#56)
1 parent 89af5ac commit 8831dfd

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

doc/changes/unreleased.md

+3
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
# Unreleased
2+
3+
## Features
4+
- #55 Added publicly callable function finding the database id from its name.

exasol/saas/client/api_access.py

+20-3
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ def _get_database_id(
8383
database_name: str,
8484
) -> str:
8585
"""
86-
Finds the database id, given an optional database name. If the name is not
87-
provided returns an id of any non-deleted database. The latter option may be
88-
useful for testing.
86+
Finds the database id, given the database name.
8987
"""
9088
dbs = list_databases.sync(account_id, client=client)
9189
dbs = list(filter(lambda db: (db.name == database_name) and # type: ignore
@@ -96,6 +94,25 @@ def _get_database_id(
9694
return dbs[0].id
9795

9896

97+
def get_database_id(
98+
host: str,
99+
account_id: str,
100+
pat: str,
101+
database_name: str,
102+
) -> str:
103+
"""
104+
Finds the database id, given the database name.
105+
106+
Args:
107+
host: SaaS service URL.
108+
account_id: User account ID
109+
pat: Personal Access Token.
110+
database_name: Database name.
111+
"""
112+
with create_saas_client(host, pat) as client:
113+
return _get_database_id(account_id, client, database_name)
114+
115+
99116
def get_connection_params(
100117
host: str,
101118
account_id: str,

0 commit comments

Comments
 (0)