Python使用pymysql
from . import config
import pymysql
class Mysql:
def __init__(self):
self.conn()
def conn(self):
self.conn = pymysql.connect(
host = config.DB.get('HOST'),
user = config.DB.get('USER'),
password = config.DB.get('PASSWORD'),
database = config.DB.get('DATABASE'),
charset = config.DB.get('CHARSET'),
)
self.cursor = self.conn.cursor(cursor = pymysql.cursors.DictCursor)
def close(self):
self.cursor.close()
self.conn.close()
本文标题:Python使用pymysql
本文链接:https://www.haomeiwen.com/subject/kegwlhtx.html
网友评论