Skip to main content

常用工具类方法集合

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"}
# 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.5

Mysql insert语句执行的时候,忽略值为None的字段。

1.3.8

可以通过check_requirement方法检测依赖包是否已经安装,如果没有安装,则提示安装。

Project details


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.5.6.tar.gz (9.6 kB view details)

Uploaded Source

File details

Details for the file wcommon-1.5.6.tar.gz.

File metadata

  • Download URL: wcommon-1.5.6.tar.gz
  • Upload date:
  • Size: 9.6 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/1.5.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for wcommon-1.5.6.tar.gz
Algorithm Hash digest
SHA256 4d10ff7ede41c3f211f651f91ed485db224d3e6b9380e3300e6e7d367862cb21
MD5 7ae50ae45963a2e4d139494fd12deeb6
BLAKE2b-256 a876ce425e26ad899d8e04e422b1b6bdc094ff0af28383fb6e367d2fc95a04b6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page