Metadata-Version: 2.4
Name: ddump
Version: 0.3.3
Summary: A data dump tool
Author-email: wukan <wu-kan@163.com>
License: MIT License
        
        Copyright (c) 2022 wukan
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Requires-Python: >=3.6
Requires-Dist: ksrpc>=0.6.8
Requires-Dist: loguru
Requires-Dist: more-itertools
Requires-Dist: pandas
Requires-Dist: pyarrow
Requires-Dist: pymysql
Requires-Dist: sqlalchemy>=1.4
Requires-Dist: tenacity
Description-Content-Type: text/markdown

# ddump
ddump(Data Dump)数据转存工具。主要解决以下问题：
1. 数据库的增量转存
2. API数据转存的通用模式
3. 数据的本地文件组织方案

本工具定位是数据下载，文件目录和文件名的组织方式以实现增量下载和减少下载量为首要目标，读取是否方便为次要目标。  
用户可能需要根据自己的使用习惯，将数据转存成其它格式，如导入到数据库等

## 为何使用文件存储，而不用数据库
1. 没有表结构的情况下，to_sql保存格式的效率很低，提前准备表结构又麻烦
2. 金融类数据特殊，并不需要随机访问。全量加载或按日期加载都是更常用的方法
3. 数据备份分享时，文件更方便

## 为何采用Parquet文件格式
1. csv格式，文本格式，读写慢，容易丢失精度
2. pickle格式，只能在Python下使用
3. HDF5格式，强大灵活，跨语言
4. parquet格式，列式存储，支持直接读取文件夹。跨语言，常用于大数据处理

## 安装
> pip install ddump -i https://pypi.tuna.tsinghua.edu.cn/simple --upgrade # 国内镜像下载

> pip install ddump -i https://pypi.org/simple --upgrade # 国外官方源下载

## 开发
> pip install -e .


## 数据库转存
请访问 [数据库转存文档](ddump/db/README.md)

## API转存
请访问 [API转存文档](ddump/api/README.md)

## 数据库工具
在开发本项目时，提炼了一个数据库ORM工具，它是对sqlalchemy的进一步封装，简单易用，可以直接映射已经存在的表。使用方法仿照聚宽的数据接口。
```python
from ddump.db.tool import DbTool

db = DbTool(url="mysql+pymysql://user:pasword@127.0.0.1:3306/tushare?charset=utf8")
db.show_tables()

db.describe('FDT_STK_AUDIT')

q = db.query(db.FDT_STK_AUDIT).limit(10)
df = db.run_query(q)
df

```

## 样例
参考 [examples](examples)，内有常见的几个库的调用示例，欢迎大家提供更多的案例
