A functional enhancement package that focus on crud based PyMySQL
Project description
PyMySQLPlus
不想使用繁琐的ORM框架?又想具备一定的ORM功能?来使用PyMySQLPlus吧!
PyMySQLPlus是建立在PyMySQL上的功能增强库,方便用户进行简单的进行CRUD;
你只需要简单两步,就可以获得基本的CRUD功能!无需在去使用繁琐的ORM框架!
Requirements
termcolor
Install
$ pip install pymysql-curd
Example
假设有下面一个class
表
create table class (
id bigint(20) primary key auto_increment,
class_name varchar(50) not null unique,
is_delete tinyint default 0,
index idx_clsname(class_name)
)engine=innodb
auto_increment=1
default charset=utf8;
使用pymysqlplus轻松的进行CRUD
import pymysql
from pymysqldao import BaseDao
db_example_conn = pymysql.connect(
host='localhost',
user='root',
password='root',
database='python_example',
cursorclass=pymysql.cursors.DictCursor
)
class ClassDao(BaseDao):
def __init__(self):
super(ClassDao, self).__init__()
self.connection = db_example_conn
self.table_name = "class"
if __name__ == '__main__':
class_dao = ClassDao()
# select by id
class_dao.select_by_id(1)
class_dao.select_by_id("1")
class_dao.select_by_id(1, primary_key="id")
# select by field
class_dao.select_by_field("xxx", field_key="class_name")
class_dao.select_by_field("xxx", field_key="class_name", limit_size=10)
# select list
class_dao.select_list()
class_dao.select_list(limit_size=500)
# select by id_list
class_dao.select_by_id_list([1, 2, 3]) # default primary_key is "id"
class_dao.select_by_id_list([1, 2, 3], primary_key="class_id")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pymysql_dao-0.0.3.tar.gz
(6.6 kB
view details)
Built Distribution
File details
Details for the file pymysql_dao-0.0.3.tar.gz
.
File metadata
- Download URL: pymysql_dao-0.0.3.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b37e62685729c0352e6ef3a348d95df20503581fc3d1bae35e50ac955eb4a424 |
|
MD5 | d8b6a8b24065985aceafd2e459eff7a4 |
|
BLAKE2b-256 | 4f384e1ece785b20778e7074f82fc362e5d789aab5ca41b274eae48c13a9bd3c |
File details
Details for the file pymysql_dao-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: pymysql_dao-0.0.3-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70cbc36f7556fbed8a8da56e0c6e75660f8508e7d5d626671b9f58f7ec9bb3e6 |
|
MD5 | fb81a2f40ca473b3fb18e9f948581014 |
|
BLAKE2b-256 | ebaf278436bd3dab2b6ef3d565a42e7136e5c0e5cca6fe99160631a5d742a07c |