Metadata-Version: 2.1
Name: k2magic
Version: 0.1.7
Summary: K2data内部的数据分析工具包
Home-page: https://www.k2data.com.cn
Author: K2data
Author-email: admin@k2data.com.cn
License: MIT License
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: pandas
Requires-Dist: requests
Requires-Dist: sqlalchemy

# k2magic
K2Magic是K2Assets提供的数据分析开发包（以下简称SDK），用于简化Python里访问各类数据库的操作。

### 安装sdk

执行以下命令安装：
```
pip install k2magic
```

### 使用sdk

使用方法详见`DataFrameDB`类的帮助文档，下面是一个快速示例：

```
>>> import pandas as pd
>>> from k2magic.dataframe_db import DataFrameDB
>>> 
>>> db = DataFrameDB('postgresql+psycopg2://...')
>>> df = db.select('table1', condition='col1 > 1')
>>> df = db.select('table1', limit=3, order_by=['k_device DESC'])
>>> data = {'k_device': ['a', 'b', 'c'], 'col1': [1, 2, 3], 'col2': [4, 5, 6]}
>>> df = pd.DataFrame(data)
>>> db.delete('table1')
>>> db.insert('table1', df)
>>> db.update('table1', df, index_keys=['k_device'])
>>> db.upsert('table1', df, index_keys=['k_device'])
```
