Skip to main content

No project description provided

Project description

description

这是第一个对外发布的模块,基于pymysql1.1.0进行的封装。
功能:报错后自动关闭sql连接,py编写sql更友好。

参数解析:

config: 配置对象,用于连接数据库
sql: sql语句
args:用的pymysql里面的args【type: list or tuple】
db_name:数据库名称
table_name:表名称
size:每次查询的条数

配置对象

config = {
    'host': '192.168.93.131',  # 必传
    'port': 3306,  # 可选参数
    'user': 'root',  # 必传参数
    'password': 'Tomboy_test',  # 必传参数
    'db': 'test',  # 可选参数
}

功能

1.DML合并:
    都是changeRows方法
    params:
        sql:sql语句
        args:用来替换sql语句中的%s的参数
    return:
        受影响的行数或者None,只有rows>0才会被commit

2.查询合并:
    查询所有:
        mydb.queryRows(sql, args)
    查询一条:
        mydb.queryOneRow(sql, args, size=1)
    查询前n条:
        mydb.queryManyRows(sql, args, size=n)

3.报错后自动回滚 + 断开数据库连接,回收资源

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

mydb_tsm-1.0.1.tar.gz (4.6 kB view details)

Uploaded Source

File details

Details for the file mydb_tsm-1.0.1.tar.gz.

File metadata

  • Download URL: mydb_tsm-1.0.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for mydb_tsm-1.0.1.tar.gz
Algorithm Hash digest
SHA256 9667ce1c6262a99c085c7ae4d9b741108159fc8ad100dca49baf8f7ed3fc6e5e
MD5 fe8daf8a77185774f47829a1c887ab2e
BLAKE2b-256 f085cc20f5aa6f993744541c675cb56d14f9cb3597c4f1d0b44ceeba22447f80

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