Skip to content

Commit 747183f

Browse files
committed
figure out Unclosed client session warning and fix it
1 parent 4ac87b9 commit 747183f

4 files changed

Lines changed: 16 additions & 5 deletions

File tree

ClickSQL/clickhouse/ClickHouse.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def __init__(self, **db_settings):
107107
self.http_settings = self._merge_settings(None, updated_settings=self._default_settings)
108108
self.http_settings.update({'user': self._para.user, 'password': self._para.password})
109109

110-
self._session = ClientSession()
110+
# self._session = ClientSession()
111111
self.max_async_query_once = 5
112112
self.is_closed = False
113113

@@ -270,7 +270,6 @@ def execute(self, *sql, convert_to: str = 'dataframe', loop=None, ):
270270
:param loop:
271271
:return:
272272
"""
273-
## TODO warning: Unclosed client session
274273

275274
insert_process = list(map(lambda x: x.lower().startswith(available_queries_insert), sql))
276275
select_process = list(map(lambda x: x.lower().startswith(available_queries_select), sql))

ClickSQL/clickhouse/ClickHouseExt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# coding=utf-8
22
import pandas as pd
33
import numpy as np
4-
4+
import re
55

66
class ClickHouseTableNodeExt(object):
77
@classmethod
@@ -191,7 +191,7 @@ def _create_table_from_df(cls, db: str, table: str, df: pd.DataFrame, key_cols:
191191
dtypes_dict = {k: v for k, v in dtypes_dict.items() if k in cols}
192192
base = cls._create_table_from_sql(db, table, dtypes_dict, key_cols, engine_type=engine_type,
193193
extra_format_dict=extra_format_dict, partitions_expr=partitions_expr)
194-
exist_status = cls._check_table_exists(obj, db, table)
194+
# exist_status = cls._check_table_exists(obj, db, table)
195195

196196
query_func(base)
197197
return exist_status

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,16 @@ more information for ClickHouse can be found at [here](http://clickhouse.tech)
1919

2020
## Usage
2121

22+
```python
23+
from ClickSQL import ClickHouseTableNode
24+
25+
conn_str = "clickhouse://default:test121231@99.99.9.9:8123/system"
26+
ClickHouseTableNode(conn_str)
27+
28+
>>> connection test: Ok.
29+
30+
```
31+
32+
2233

2334

test/testing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from ClickSQL import ClickHouseTableNode
44

55
if __name__ == '__main__':
6-
print(ClickHouseTableNode)
6+
conn_str = "clickhouse://default:Imsn0wfree@47.104.186.157:8123/system"
7+
cf = ClickHouseTableNode(conn_str)
78

89
pass

0 commit comments

Comments
 (0)