常用工具类方法集合
Project description
This is my common Python tool classes.
Main page is https://pypi.org/project/wcommon/ .
/data/apps/public/conf.ini content like:
[mysql]
host=example.com
port=3306
user=username
passwd=password
database=test
charset=utf8mb4
Find the localhost internal network ip:
from wcommon import *
ip = getLocalIp()
hostname = getLocalHostname()
Decode unusual json string:
from wcommon import *
line = """
{
name:'java',
system:'linux'
}
"""
result = dejson(line)
# output result
{"name":"java","system":"linux"}
# check the reuquirement list
check_requirement(['requests','flask'])
Operate mysql data:
mysql = Mysql(configuraion_file="/data/apps/public/conf.ini", section="mysql")
# query
rows = mysql.query("select * from example_table where status = %s order by id desc limit %s",(1,10))
for row in rows:
print(row)
# bulk_insert
mysql.bulk_insert("test.person",["name","age"],[["mahuateng",40],["liyanhong",39]])
# bulk_insert
mysql.bulk_insert2("test.person",[{"name":"ma2","age":40},{"name":"liyanhong2","age":39},{"name":"ren"}] )
Feature
1.3.8
可以通过check_requirement方法检测依赖包是否已经安装,如果没有安装,则提示安装。
1.6.5
为Elasticsearch增加query方法
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
wcommon-1.6.5.tar.gz
(11.2 kB
view details)
File details
Details for the file wcommon-1.6.5.tar.gz.
File metadata
- Download URL: wcommon-1.6.5.tar.gz
- Upload date:
- Size: 11.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d2e6f628d0e356be23a6eac6ec7f4a77838189b1b6e1c81e51d1e4de64505ff
|
|
| MD5 |
010a6195b554b6d7a658df67cf7e88d0
|
|
| BLAKE2b-256 |
04eca8e6899814e61cf8456777023d166c6290b9b4fae0455b54128f9dcaa69e
|