常用工具类方法集合
Project description
This is my common Python tool classes.
/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"}
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"}] )
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.2.9.tar.gz
(8.1 kB
view details)
File details
Details for the file wcommon-1.2.9.tar.gz.
File metadata
- Download URL: wcommon-1.2.9.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.26.0 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.1 keyring/23.1.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a122e7136d64fc92ea824c0335cebe92672355a9c30ae44eeb30e483efd44345
|
|
| MD5 |
d6e4a8d4d9e9c9ddb8c7fb4b9537143d
|
|
| BLAKE2b-256 |
f6cac966e724fbbb96029b475d2031ec451b2ba4da05e250d2193be370ccb63e
|