Skip to main content

A tool for importing Excel files to MySQL database

Project description

Excel to DB

一个用于将 Excel 文件批量导入到 MySQL 数据库的 Python 工具。

安装

  1. 从 PyPI 安装
pip install excel-to-db
  1. 从源码安装
git clone https://github.com/yourusername/excel_to_db.git
cd excel_to_db
pip install -e .

使用方法

  1. 命令行使用
# 生成配置文件
excel2db init-config -o config.yml

# 导入单个文件
excel2db import-file example.xlsx

# 批量导入目录下的文件
excel2db batch-import --directory excel_files

# 测试数据库连接
excel2db test-connection
  1. Python API 使用
from excel_to_db import ExcelProcessor, DBConfig

# 配置数据库
db_config = DBConfig.create_config(
    host='your_host',
    user='your_username',
    password='your_password',
    database='your_database'
)

# 初始化处理器
processor = ExcelProcessor(db_config)

# 处理单个文件
processor.process_excel("path/to/your/excel_file.xlsx")

配置文件

配置文件使用 YAML 格式:

database:
  host: localhost
  user: root
  password: password
  database: test_db
  connect_timeout: 10

excel:
  directory: excel_files
  batch_size: 5000

logging:
  level: INFO
  directory: logs

支持的数据表

文件关键词 数据库表名 说明
销售/sell/sale sales_detail 销售明细数据
门店信息/store/shop store_info 门店基础信息
目标/target store_target 门店目标数据
产品/product product_mapping 产品信息映射
库存/inventory physical_inventory 实物库存数据
战役/campaign campaign_target 战役目标数据
服务/service service_mapping 服务信息映射
验机/device device_acceptance 电子验机数据

开发指南

  1. 安装开发依赖
pip install -r requirements-dev.txt
  1. 运行测试
pytest tests/
  1. 代码格式化
black src/excel_to_db tests examples

许可证

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

excel_to_db-1.2.3.tar.gz (15.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

excel_to_db-1.2.3-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file excel_to_db-1.2.3.tar.gz.

File metadata

  • Download URL: excel_to_db-1.2.3.tar.gz
  • Upload date:
  • Size: 15.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for excel_to_db-1.2.3.tar.gz
Algorithm Hash digest
SHA256 74b2a8130598c2f771a9e9cf2c3cf2a2e083dd024622897e23a1ef5618da0900
MD5 bb0ddf7ac28ccce2290dc5a6cb3a188a
BLAKE2b-256 1d747fa8e1000acea13bedb2867f8438f3e7252a9f803b4d2f0f76153b9379f7

See more details on using hashes here.

File details

Details for the file excel_to_db-1.2.3-py3-none-any.whl.

File metadata

  • Download URL: excel_to_db-1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.13

File hashes

Hashes for excel_to_db-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 4c5ae93d4bdeaf69c35d8ae542564d397e24bc95551f1209ee29a5b67eaa9775
MD5 cb0a5fe5be19441893b31a0152bcc020
BLAKE2b-256 3dcd7154eda29ccb6ac0d0aeac15607de2475cfe265eabe0d2ccecb29f7dea2a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page