Name | excel-to-db JSON |
Version |
1.2.4
JSON |
| download |
home_page | https://github.com/yourusername/excel_to_db |
Summary | A tool for importing Excel files to MySQL database |
upload_time | 2025-02-07 17:21:25 |
maintainer | None |
docs_url | None |
author | Your Name |
requires_python | >=3.6 |
license | MIT License
Copyright (c) 2024 Your Name
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. |
keywords |
excel
mysql
database
import
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Excel to DB
一个用于将 Excel 文件批量导入到 MySQL 数据库的 Python 工具。
## 安装
1. **从 PyPI 安装**
```bash
pip install excel-to-db
```
2. **从源码安装**
```bash
git clone https://github.com/yourusername/excel_to_db.git
cd excel_to_db
pip install -e .
```
## 使用方法
1. **命令行使用**
```bash
# 生成配置文件
excel2db init-config -o config.yml
# 导入单个文件
excel2db import-file example.xlsx
# 批量导入目录下的文件
excel2db batch-import --directory excel_files
# 测试数据库连接
excel2db test-connection
```
2. **Python API 使用**
```python
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 格式:
```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. **安装开发依赖**
```bash
pip install -r requirements-dev.txt
```
2. **运行测试**
```bash
pytest tests/
```
3. **代码格式化**
```bash
black src/excel_to_db tests examples
```
## 许可证
MIT License
Raw data
{
"_id": null,
"home_page": "https://github.com/yourusername/excel_to_db",
"name": "excel-to-db",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "excel, mysql, database, import",
"author": "Your Name",
"author_email": "Your Name <your.email@example.com>",
"download_url": "https://files.pythonhosted.org/packages/bf/60/96f4fac362c2136ecbc2969dc81e97e4f48ce76b27c828e74d45b0d769ef/excel_to_db-1.2.4.tar.gz",
"platform": null,
"description": "# Excel to DB\r\n\r\n\u4e00\u4e2a\u7528\u4e8e\u5c06 Excel \u6587\u4ef6\u6279\u91cf\u5bfc\u5165\u5230 MySQL \u6570\u636e\u5e93\u7684 Python \u5de5\u5177\u3002\r\n\r\n## \u5b89\u88c5\r\n\r\n1. **\u4ece PyPI \u5b89\u88c5**\r\n```bash\r\npip install excel-to-db\r\n```\r\n\r\n2. **\u4ece\u6e90\u7801\u5b89\u88c5**\r\n```bash\r\ngit clone https://github.com/yourusername/excel_to_db.git\r\ncd excel_to_db\r\npip install -e .\r\n```\r\n\r\n## \u4f7f\u7528\u65b9\u6cd5\r\n\r\n1. **\u547d\u4ee4\u884c\u4f7f\u7528**\r\n\r\n```bash\r\n# \u751f\u6210\u914d\u7f6e\u6587\u4ef6\r\nexcel2db init-config -o config.yml\r\n\r\n# \u5bfc\u5165\u5355\u4e2a\u6587\u4ef6\r\nexcel2db import-file example.xlsx\r\n\r\n# \u6279\u91cf\u5bfc\u5165\u76ee\u5f55\u4e0b\u7684\u6587\u4ef6\r\nexcel2db batch-import --directory excel_files\r\n\r\n# \u6d4b\u8bd5\u6570\u636e\u5e93\u8fde\u63a5\r\nexcel2db test-connection\r\n```\r\n\r\n2. **Python API \u4f7f\u7528**\r\n\r\n```python\r\nfrom excel_to_db import ExcelProcessor, DBConfig\r\n\r\n# \u914d\u7f6e\u6570\u636e\u5e93\r\ndb_config = DBConfig.create_config(\r\n host='your_host',\r\n user='your_username',\r\n password='your_password',\r\n database='your_database'\r\n)\r\n\r\n# \u521d\u59cb\u5316\u5904\u7406\u5668\r\nprocessor = ExcelProcessor(db_config)\r\n\r\n# \u5904\u7406\u5355\u4e2a\u6587\u4ef6\r\nprocessor.process_excel(\"path/to/your/excel_file.xlsx\")\r\n```\r\n\r\n## \u914d\u7f6e\u6587\u4ef6\r\n\r\n\u914d\u7f6e\u6587\u4ef6\u4f7f\u7528 YAML \u683c\u5f0f\uff1a\r\n\r\n```yaml\r\ndatabase:\r\n host: localhost\r\n user: root\r\n password: password\r\n database: test_db\r\n connect_timeout: 10\r\n\r\nexcel:\r\n directory: excel_files\r\n batch_size: 5000\r\n\r\nlogging:\r\n level: INFO\r\n directory: logs\r\n```\r\n\r\n## \u652f\u6301\u7684\u6570\u636e\u8868\r\n\r\n| \u6587\u4ef6\u5173\u952e\u8bcd | \u6570\u636e\u5e93\u8868\u540d | \u8bf4\u660e |\r\n|-----------|------------|------|\r\n| \u9500\u552e/sell/sale | sales_detail | \u9500\u552e\u660e\u7ec6\u6570\u636e |\r\n| \u95e8\u5e97\u4fe1\u606f/store/shop | store_info | \u95e8\u5e97\u57fa\u7840\u4fe1\u606f |\r\n| \u76ee\u6807/target | store_target | \u95e8\u5e97\u76ee\u6807\u6570\u636e |\r\n| \u4ea7\u54c1/product | product_mapping | \u4ea7\u54c1\u4fe1\u606f\u6620\u5c04 |\r\n| \u5e93\u5b58/inventory | physical_inventory | \u5b9e\u7269\u5e93\u5b58\u6570\u636e |\r\n| \u6218\u5f79/campaign | campaign_target | \u6218\u5f79\u76ee\u6807\u6570\u636e |\r\n| \u670d\u52a1/service | service_mapping | \u670d\u52a1\u4fe1\u606f\u6620\u5c04 |\r\n| \u9a8c\u673a/device | device_acceptance | \u7535\u5b50\u9a8c\u673a\u6570\u636e |\r\n\r\n## \u5f00\u53d1\u6307\u5357\r\n\r\n1. **\u5b89\u88c5\u5f00\u53d1\u4f9d\u8d56**\r\n```bash\r\npip install -r requirements-dev.txt\r\n```\r\n\r\n2. **\u8fd0\u884c\u6d4b\u8bd5**\r\n```bash\r\npytest tests/\r\n```\r\n\r\n3. **\u4ee3\u7801\u683c\u5f0f\u5316**\r\n```bash\r\nblack src/excel_to_db tests examples\r\n```\r\n\r\n## \u8bb8\u53ef\u8bc1\r\n\r\nMIT License\r\n",
"bugtrack_url": null,
"license": "MIT License\r\n \r\n Copyright (c) 2024 Your Name\r\n \r\n Permission is hereby granted, free of charge, to any person obtaining a copy\r\n of this software and associated documentation files (the \"Software\"), to deal\r\n in the Software without restriction, including without limitation the rights\r\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\n copies of the Software, and to permit persons to whom the Software is\r\n furnished to do so, subject to the following conditions:\r\n \r\n The above copyright notice and this permission notice shall be included in all\r\n copies or substantial portions of the Software.\r\n \r\n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n SOFTWARE. ",
"summary": "A tool for importing Excel files to MySQL database",
"version": "1.2.4",
"project_urls": {
"Homepage": "https://github.com/yourusername/excel_to_db",
"Repository": "https://github.com/yourusername/excel_to_db.git"
},
"split_keywords": [
"excel",
" mysql",
" database",
" import"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "d0645b228b79f6a9d76ee93ef9ad155c7a91ceea915a9bf2211aa535133ea38a",
"md5": "bf13e792fa228b5c100fcae83c323492",
"sha256": "a79960d7c149e0177eae5ee39c4517d881e4c728bd39c674a87939e593933b81"
},
"downloads": -1,
"filename": "excel_to_db-1.2.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bf13e792fa228b5c100fcae83c323492",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 15085,
"upload_time": "2025-02-07T17:21:24",
"upload_time_iso_8601": "2025-02-07T17:21:24.287024Z",
"url": "https://files.pythonhosted.org/packages/d0/64/5b228b79f6a9d76ee93ef9ad155c7a91ceea915a9bf2211aa535133ea38a/excel_to_db-1.2.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "bf6096f4fac362c2136ecbc2969dc81e97e4f48ce76b27c828e74d45b0d769ef",
"md5": "a7afda6fa040370444efedea8f31d090",
"sha256": "a3641e039251e61d4a7eca10c87136349d73140a0c9ad305a16dbfb6264f06be"
},
"downloads": -1,
"filename": "excel_to_db-1.2.4.tar.gz",
"has_sig": false,
"md5_digest": "a7afda6fa040370444efedea8f31d090",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 16597,
"upload_time": "2025-02-07T17:21:25",
"upload_time_iso_8601": "2025-02-07T17:21:25.576492Z",
"url": "https://files.pythonhosted.org/packages/bf/60/96f4fac362c2136ecbc2969dc81e97e4f48ce76b27c828e74d45b0d769ef/excel_to_db-1.2.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-07 17:21:25",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yourusername",
"github_project": "excel_to_db",
"github_not_found": true,
"lcname": "excel-to-db"
}