项目用到了python,习惯了TP的链式操作,自己动手写了一个python的Model层 实现了Pymysql的原生连接和dbutils的连接池连接 模型基类: # coding: utf-8 import pymysql import threading from Include.Logger import get_logger from Include.Setting import app_settings from dbutils.pooled_db import PooledDB class MysqlPool: config = { 'creator': pymysql, 'host': app_settings.get('ManagerHost', '127.0.0.1'), 'port': int(app_settings.get('DBPort', 3306)), 'user': app_settings.get('DBUser', 'root'), 'password': app_settings.get('DBPwd', ''), 'db': app_settings.get('DBName', ''), 'charset': app_settings.get('DBCharSet', 'utf8'), 'maxconnections': 30, # 连接池最大连接数 'cursorclass': pymysql.cursors.DictCursor } pool = PooledDB(**config) def……
阅读全文