|
5 | 5 |
|
6 | 6 | import firebolt.db as dbapi |
7 | 7 | import sqlalchemy.types as sqltypes |
| 8 | +from firebolt.client.auth import UsernamePassword |
8 | 9 | from firebolt.db import Cursor |
9 | 10 | from sqlalchemy.engine import Connection as AlchemyConnection |
10 | 11 | from sqlalchemy.engine import ExecutionContext, default |
@@ -101,24 +102,22 @@ def __init__( |
101 | 102 | def dbapi(cls) -> ModuleType: |
102 | 103 | return dbapi |
103 | 104 |
|
104 | | - # Build firebolt-sdk compatible connection arguments. |
105 | | - # URL format : firebolt://username:password@host:port/db_name |
106 | 105 | def create_connect_args(self, url: URL) -> Tuple[List, Dict]: |
| 106 | + """ |
| 107 | + Build firebolt-sdk compatible connection arguments. |
| 108 | + URL format : firebolt://username:password@host:port/db_name |
| 109 | + """ |
| 110 | + parameters = dict(url.query) |
| 111 | + # parameters are all passed as a string, we need to convert |
| 112 | + # bool flag to boolean for SDK compatibility |
| 113 | + token_cache_flag = bool(strtobool(parameters.pop("use_token_cache", "True"))) |
107 | 114 | kwargs = { |
108 | 115 | "database": url.host or None, |
109 | | - "username": url.username or None, |
110 | | - "password": url.password or None, |
| 116 | + "auth": UsernamePassword(url.username, url.password, token_cache_flag), |
111 | 117 | "engine_name": url.database, |
112 | 118 | } |
113 | | - parameters = dict(url.query) |
114 | 119 | if "account_name" in parameters: |
115 | 120 | kwargs["account_name"] = parameters.pop("account_name") |
116 | | - if "use_token_cache" in parameters: |
117 | | - # parameters are all passed as a string, we need to convert it |
118 | | - # to boolean for SDK compatibility |
119 | | - kwargs["use_token_cache"] = bool( |
120 | | - strtobool(parameters.pop("use_token_cache")) |
121 | | - ) |
122 | 121 | self._set_parameters = parameters |
123 | 122 | # If URL override is not provided leave it to the sdk to determine the endpoint |
124 | 123 | if "FIREBOLT_BASE_URL" in os.environ: |
|
0 commit comments