#!/usr/bin/python
# -*- coding: UTF-8 -*-
import pymysql
def get_connection():
url = "127.0.0.1"
database = "analyzer"
user = "root"
password = "toor"
charset = "utf8"
return pymysql.connect(host=url, port=3306, user=user, passwd=password, db=database, charset=charset)
class MysqlHelper:
def query(self, sql):
conn = get_connection()
cursor = conn.cursor()
cursor.execute(sql)
result = cursor.fetchall()
cursor.close()
conn.close()
return result
python3.5 mysql helper
猜你喜欢
转载自blog.csdn.net/ecjtusanhu/article/details/102461659
今日推荐
周排行