ddump
ddump(Data Dump)数据转存工具。主要解决以下问题:
- 数据库的增量转存
- API数据转存的通用模式
- 数据的本地文件组织方案
本工具定位是数据下载,文件目录和文件名的组织方式以实现增量下载和减少下载量为首要目标,读取是否方便为次要目标。
用户可能需要根据自己的使用习惯,将数据转存成其它格式,如导入到数据库等
为何使用文件存储,而不用数据库
- 没有表结构的情况下,to_sql保存格式的效率很低,提前准备表结构又麻烦
- 金融类数据特殊,并不需要随机访问。全量加载或按日期加载都是更常用的方法
- 数据备份分享时,文件更方便
为何采用Parquet文件格式
- csv格式,文本格式,读写慢,容易丢失精度
- pickle格式,只能在Python下使用
- HDF5格式,强大灵活,跨语言
- 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 .
数据库转存
请访问 数据库转存文档
API转存
请访问 API转存文档
数据库工具
在开发本项目时,提炼了一个数据库ORM工具,它是对sqlalchemy的进一步封装,简单易用,可以直接映射已经存在的表。使用方法仿照聚宽的数据接口。
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,内有常见的几个库的调用示例,欢迎大家提供更多的案例
Metadata
Release files for ddump 0.3.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ddump-0.3.5.tar.gz | 22.7 kB | Without provenance | Details for ddump-0.3.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ddump-0.3.5-py3-none-any.whl | Python 3 | none | any | Details for ddump-0.3.5-py3-none-any.whl |
Total release size: 53.2 kB
Release files / ddump-0.3.5.tar.gz
| Download URL | ddump-0.3.5.tar.gz |
|---|---|
| Size | 22.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5283a4b6ef95b9435be088b99f9eb84d46a7f123409c79a6c3935b71c9e09d89
|
|
BLAKE2b-256 checksum How to use checksums |
a63b1dd6d6ba5a9a3254dc50bac393e03e4ad2ce6b207595b074149e5fc0ad42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / ddump-0.3.5-py3-none-any.whl
| Download URL | ddump-0.3.5-py3-none-any.whl |
|---|---|
| Size | 30.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8d232e3c14d05c108c71e054c3bee168985c15a9291ea89588788dcdc144233c
|
|
BLAKE2b-256 checksum How to use checksums |
a126efa5d28b6bc36741c48e57e2da99e99ea15a1a9d43d8e9f5383135ffa068
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Security for ddump 0.3.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.