# pypdm-db
> mysql/sqlite 的 PDM 生成器
------
## 运行环境
![](https://img.shields.io/badge/Python-3.8%2B-brightgreen.svg) ![](https://img.shields.io/badge/PyCharm-4.0.4%2B-brightgreen.svg)
## 安装说明
执行脚本:
```
python -m pip install --upgrade pip
python -m pip install pypdm-db
```
## 使用指引
示例代码可参考单元测试:
- sqlite: [test_pypdm_sqlite.py](tests/test_pypdm_sqlite.py)
- mysql: [test_pypdm_mysql.py](tests/test_pypdm_mysql.py)
通过以下函数可生成对应数据库的连接对象:
- `from pypdm.dbc._sqlite import SqliteDBC`
- `from pypdm.dbc._mysql import MysqlDBC`
通过函数 `from pypdm.builder import build` 可生成指定数据表的 PDM 文件。
例如数据库中已有表 [`t_teachers`](tests/db/sqlite/init_db.sql) ,会在指定的 package 目录生成两个代码文件:
- Bean 文件: [*/bean/t_teachers.py](tests/tmp/pdm/sqlite/bean/t_teachers.py)
- DAO 文件: [*/dao/t_teachers.py](tests/tmp/pdm/sqlite/dao/t_teachers.py)
其中 Bean 文件与表 `t_teachers` 的表结构一一对应, DAO 文件则封装了针对表 `t_teachers` 的增删改查函数。利用这两个文件,就可以方便地对表 `t_teachers` 进行操作。
Raw data
{
"_id": null,
"home_page": "https://github.com/lyy289065406/pypdm-db",
"name": "pypdm-db",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.5",
"maintainer_email": null,
"keywords": "pypdm, sqlite, mysql, pdm",
"author": "EXP",
"author_email": "289065406@qq.com",
"download_url": "https://files.pythonhosted.org/packages/d0/d4/81dadb43c0fb64236e2a18013e40c046229f18f21c45758628b5d3f73f16/pypdm_db-1.1.6.tar.gz",
"platform": null,
"description": "# pypdm-db\n\n> mysql/sqlite \u7684 PDM \u751f\u6210\u5668\n\n------\n\n## \u8fd0\u884c\u73af\u5883\n\n![](https://img.shields.io/badge/Python-3.8%2B-brightgreen.svg) ![](https://img.shields.io/badge/PyCharm-4.0.4%2B-brightgreen.svg)\n\n\n## \u5b89\u88c5\u8bf4\u660e\n\n\u6267\u884c\u811a\u672c\uff1a \n\n```\npython -m pip install --upgrade pip\npython -m pip install pypdm-db\n```\n\n\n## \u4f7f\u7528\u6307\u5f15\n\n\u793a\u4f8b\u4ee3\u7801\u53ef\u53c2\u8003\u5355\u5143\u6d4b\u8bd5\uff1a\n\n- sqlite: [test_pypdm_sqlite.py](tests/test_pypdm_sqlite.py)\n- mysql: [test_pypdm_mysql.py](tests/test_pypdm_mysql.py)\n\n\u901a\u8fc7\u4ee5\u4e0b\u51fd\u6570\u53ef\u751f\u6210\u5bf9\u5e94\u6570\u636e\u5e93\u7684\u8fde\u63a5\u5bf9\u8c61\uff1a\n\n- `from pypdm.dbc._sqlite import SqliteDBC`\n- `from pypdm.dbc._mysql import MysqlDBC`\n\n\u901a\u8fc7\u51fd\u6570 `from pypdm.builder import build` \u53ef\u751f\u6210\u6307\u5b9a\u6570\u636e\u8868\u7684 PDM \u6587\u4ef6\u3002\n\n\u4f8b\u5982\u6570\u636e\u5e93\u4e2d\u5df2\u6709\u8868 [`t_teachers`](tests/db/sqlite/init_db.sql) \uff0c\u4f1a\u5728\u6307\u5b9a\u7684 package \u76ee\u5f55\u751f\u6210\u4e24\u4e2a\u4ee3\u7801\u6587\u4ef6\uff1a\n\n- Bean \u6587\u4ef6\uff1a [*/bean/t_teachers.py](tests/tmp/pdm/sqlite/bean/t_teachers.py)\n- DAO \u6587\u4ef6\uff1a [*/dao/t_teachers.py](tests/tmp/pdm/sqlite/dao/t_teachers.py)\n\n\n\u5176\u4e2d Bean \u6587\u4ef6\u4e0e\u8868 `t_teachers` \u7684\u8868\u7ed3\u6784\u4e00\u4e00\u5bf9\u5e94\uff0c DAO \u6587\u4ef6\u5219\u5c01\u88c5\u4e86\u9488\u5bf9\u8868 `t_teachers` \u7684\u589e\u5220\u6539\u67e5\u51fd\u6570\u3002\u5229\u7528\u8fd9\u4e24\u4e2a\u6587\u4ef6\uff0c\u5c31\u53ef\u4ee5\u65b9\u4fbf\u5730\u5bf9\u8868 `t_teachers` \u8fdb\u884c\u64cd\u4f5c\u3002\n\n\n",
"bugtrack_url": null,
"license": null,
"summary": "a library for generating PDM of mysql/sqlite",
"version": "1.1.6",
"project_urls": {
"Bug Reports": "https://github.com/lyy289065406/pypdm-db/issues",
"Funding": "https://github.com/lyy289065406/pypdm-db/blob/master/imgs/donate-alipay.png",
"Homepage": "https://github.com/lyy289065406/pypdm-db",
"Say Thanks!": "https://github.com/lyy289065406/pypdm-db/blob/master/imgs/donate-wechat.png",
"Source": "https://github.com/lyy289065406/pypdm-db/"
},
"split_keywords": [
"pypdm",
" sqlite",
" mysql",
" pdm"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "bf549a02efb3908e533fc09fd20b93e585a96447a39475e3774ee3c5bf0b8132",
"md5": "6b3b8993976e929e4ac1b77d08243aba",
"sha256": "d06ed20ed5538729ee07bdb9791d19de38fc3b14db008f8fc6790b21f98efe77"
},
"downloads": -1,
"filename": "pypdm_db-1.1.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "6b3b8993976e929e4ac1b77d08243aba",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.5",
"size": 13438,
"upload_time": "2024-09-20T15:36:14",
"upload_time_iso_8601": "2024-09-20T15:36:14.335873Z",
"url": "https://files.pythonhosted.org/packages/bf/54/9a02efb3908e533fc09fd20b93e585a96447a39475e3774ee3c5bf0b8132/pypdm_db-1.1.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "d0d481dadb43c0fb64236e2a18013e40c046229f18f21c45758628b5d3f73f16",
"md5": "ad777d5e270b1e73301fc3757f615a12",
"sha256": "208efdae1d5d03015afe3128c4eed18f04cc6a6d9488ebb44fcd7ee17b891a69"
},
"downloads": -1,
"filename": "pypdm_db-1.1.6.tar.gz",
"has_sig": false,
"md5_digest": "ad777d5e270b1e73301fc3757f615a12",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.5",
"size": 15917,
"upload_time": "2024-09-20T15:36:15",
"upload_time_iso_8601": "2024-09-20T15:36:15.175505Z",
"url": "https://files.pythonhosted.org/packages/d0/d4/81dadb43c0fb64236e2a18013e40c046229f18f21c45758628b5d3f73f16/pypdm_db-1.1.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-20 15:36:15",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "lyy289065406",
"github_project": "pypdm-db",
"travis_ci": true,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "pypdm-db"
}