Skip to content

Commit ff42ed6

Browse files
committed
add some usage at README.md.
1 parent 747183f commit ff42ed6

4 files changed

Lines changed: 38 additions & 12 deletions

File tree

ClickSQL/clickhouse/ClickHouse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ def __init__(self, **db_settings):
114114
self._test_connection_()
115115

116116
@staticmethod
117-
def _check_db_settings(db_settings: dict, available_db_type=[node.__name__]): # node.__name__ : clickhouse
117+
def _check_db_settings(db_settings: dict, available_db_type=[node.__name__]): # node.__name__ : clickhouse
118118
"""
119119
it is to check db setting whether is correct!
120120
:param db_settings:

ClickSQL/clickhouse/ClickHouseExt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,52 @@ more information for ClickHouse can be found at [here](http://clickhouse.tech)
1818
`pip install ClickSQL`
1919

2020
## Usage
21+
### initial connection
2122

23+
#### *Approach 1*
2224
```python
2325
from ClickSQL import ClickHouseTableNode
2426

2527
conn_str = "clickhouse://default:test121231@99.99.9.9:8123/system"
26-
ClickHouseTableNode(conn_str)
28+
ct = ClickHouseTableNode(conn_str)
2729

2830
>>> connection test: Ok.
2931

3032
```
3133

34+
#### *Approach 2*
35+
```python
36+
from ClickSQL import ClickHouseTableNode
37+
38+
39+
40+
conn_str = {'name':'clickhouse','host':'99.99.9.9','port':8123,'user':'default',
41+
'password':'test121231','database':'system'}
42+
ct = ClickHouseTableNode(conn_str)
43+
44+
>>> connection test: Ok.
45+
46+
```
47+
### Query
48+
49+
```python
50+
from ClickSQL import ClickHouseTableNode
51+
52+
conn_str = "clickhouse://default:test121231@99.99.9.9:8123/system"
53+
ct = ClickHouseTableNode(conn_str)
54+
55+
ct.query('show tables from system limit 1')
56+
57+
>>> connection test: Ok.
58+
>>> name
59+
>>> 0 aggregate_function_combinators
60+
```
61+
62+
### Contribution
63+
there is welcome to do more work to improve this package more convenient
64+
65+
## Author
66+
sn0wfree
3267

3368

3469

test/testing.py

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)