|
17 | 17 | available_queries_select = ('select', 'show', 'desc') |
18 | 18 | available_queries_insert = ('insert', 'optimize', 'create') |
19 | 19 |
|
20 | | -SEMAPHORE = 10 |
| 20 | +SEMAPHORE = 10 # control async number for whole query list |
21 | 21 |
|
22 | 22 | from ClickSQL.conf.parse_rfc_1738_args import _parse_rfc1738_args |
23 | 23 |
|
@@ -114,7 +114,7 @@ def __init__(self, **db_settings): |
114 | 114 | self._test_connection_() |
115 | 115 |
|
116 | 116 | @staticmethod |
117 | | - def _check_db_settings(db_settings: dict, available_db_type=[node.__name__]): |
| 117 | + def _check_db_settings(db_settings: dict, available_db_type=[node.__name__]): # node.__name__ : clickhouse |
118 | 118 | """ |
119 | 119 | it is to check db setting whether is correct! |
120 | 120 | :param db_settings: |
@@ -176,7 +176,7 @@ async def _post(self, url, sql, session): |
176 | 176 | result = await resp.read() |
177 | 177 |
|
178 | 178 | status = resp.status |
179 | | - reason = resp.reason |
| 179 | + # reason = resp.reason |
180 | 180 | if status != 200: |
181 | 181 | raise ValueError(result) |
182 | 182 | return result |
@@ -292,19 +292,24 @@ def execute(self, *sql, convert_to: str = 'dataframe', loop=None, ): |
292 | 292 | to_df=to_df) |
293 | 293 | return result |
294 | 294 |
|
295 | | - def query(self, sql: str): |
| 295 | + def query(self, *sql: str): |
296 | 296 | """ |
297 | 297 | require to upgrade |
298 | 298 | :param sql: |
299 | 299 | :return: |
300 | 300 | """ |
301 | | - result = self.execute(sql, convert_to='dataframe', loop=None, ) |
| 301 | + result = self.execute(*sql, convert_to='dataframe', loop=None, ) |
302 | 302 | return result |
303 | 303 |
|
304 | 304 |
|
305 | 305 | class ClickHouseTableNode(ClickHouseBaseNode): |
306 | | - def __init__(self, conn_str: str): |
307 | | - db_settings = _parse_rfc1738_args(conn_str) |
| 306 | + def __init__(self, conn_str: (str, dict)): |
| 307 | + if isinstance(conn_str, str): |
| 308 | + db_settings = _parse_rfc1738_args(conn_str) |
| 309 | + elif isinstance(conn_str, dict): |
| 310 | + db_settings = conn_str |
| 311 | + else: |
| 312 | + raise ParameterTypeError(f'conn_str must be str or dict but get: {type(conn_str)}') |
308 | 313 | super(ClickHouseTableNode, self).__init__(**db_settings) |
309 | 314 |
|
310 | 315 | @property |
|
0 commit comments