A simple way to use Dataset. for dsm
Project description
DSM Library
DataNode
- init DataNode
from dsmlibrary.datanode import DataNode
data = DataNode(token)
- upload file
data.upload_file(directory_id=<directory_id>, file_path='<file_path>', description="<description(optional)>")
- download file
data.download_file(file_id=<file_id>, download_path="<place download file save> (default ./dsm.tmp)")
- get file
meta, file = get_file(file_id="<file_id>")
# meta -> dict
# file -> io bytes
# example read csv pandas
meta, file = get_file(file_id="<file_id>")
df = pd.read_csv(file)
...
- write parquet file
df = ... # pandas dataframe or dask dataframe
data.write(df=df, directory=<directory_id>, name=<save_file_name>, profiling=<True or False default False>)
Clickhouse
- imoprt data to clickhouse
from dsmlibrary.clickhouse import ClickHouse
ddf = ... # pandas dataframe or dask dataframe
## to warehouse
table_name = <your_table_name>
table_key = <your_table_key>
connection = {
'host': '',
'port': ,
'database': '',
'user': '',
'password': '',
'settings':{
'use_numpy': True
},
'secure': False
}
warehouse = ClickHouse(connection=connection)
tableName = warehouse.get_or_createTable(ddf=ddf, tableName=table_name, key=table_key)
warehouse.write(ddf=ddf, tableName=tableName, key=table_key)
- query data from clickhouse
query = f"""
SELECT * FROM {tableName} LIMIT 10
"""
warehouse.read(sqlQuery=query)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
dsmlibrary-1.0.10.tar.gz
(9.2 kB
view hashes)