import pymssql
class mss():#正常玩法
def __init__(self,ip,db):
server_ip = ip
username = 'sa'
userpwd = ''
db = db
self.conn = pymssql.connect(host=server_ip, user=username, password=userpwd, database=db)
self.cur = self.conn.cursor()
class mss_dict():#输出结果是DICT
def __init__(self, ip: object, db: object) -> object:
server_ip = ip
username = 'sa'
userpwd = ''
db = db
self.conn = pymssql.connect(host=server_ip, user=username, password=userpwd, database=db,as_dict=True)
self.cur = self.conn.cursor()
#备注:如果你的pymssql 版本不是2.1.4的话,连接一些GBK的数据库需要将中文先decode(‘latin1’)再encode('utf8')
网友评论