def __init__(self):
        # 想想这块如何放到配置文件里面去???
        # host = "test.lemonban.com"
        # user = "******"
        # password = "******"
        config = ReadConfig()
        host = config.get('db', 'host')
        user = config.get('db', 'user')
        password = config.get('db', 'pwd')
        port = config.getint('db', 'port')

        # 1,建立连接
        self.mysql = pymysql.connect(host=host, user=user, password=password, port=port)
        # 2,新建一个查询
        self.cursor = self.mysql.cursor()
Esempio n. 2
0
 def __init__(self, return_dict=False):
     config = ReadConfig()
     host = config.get('db', 'host')
     user = config.get('db', 'user')
     password = config.get('db', 'password')
     port = config.getint('db', 'port')
     self.mysql = pymysql.connect(host=host,
                                  user=user,
                                  password=password,
                                  port=port,
                                  charset="utf8")
     if return_dict:
         self.cursor = self.mysql.cursor(
             pymysql.cursors.DictCursor)  # 指定每行数据以字典的形式返回
     else:
         self.cursor = self.mysql.cursor()  # 此语句放在初始化里面,表示多次查询建立一个查询页面
Esempio n. 3
0
 def __init__(self, return_dict=False):
     # 1.建立连接
     config = ReadConfig()
     host = config.get('db', 'host')
     user = config.get('db', 'user')
     password = config.get('db', 'password')
     port = config.getint('db', 'port')
     self.mysql = pymysql.connect(host=host,
                                  user=user,
                                  password=password,
                                  port=port)
     if return_dict:
         self.cursor = self.mysql.cursor(
             pymysql.cursors.DictCursor)  #指定每行数据以字典的形式返回
     else:
         self.cursor = self.mysql.cursor()  #指定每行数据以元祖的形式返回
Esempio n. 4
0
    def __init__(self, return_dict=False):
        # 想想这块如何放到配置文件里面去???
        # host = "test.lemonban.com"
        # user = "******"
        # password = "******"
        config = ReadConfig()
        host = config.get('db', 'host')
        user = config.get('db', 'user')
        password = config.get('db', 'pwd')
        port = config.getint('db', 'port')

        # 1,建立连接
        self.mysql = pymysql.connect(host=host, user=user, password=password, port=port)
        # 2,新建一个查询
        if return_dict:
            self.cursor = self.mysql.cursor(pymysql.cursors.DictCursor)  # 指定每行数据以字典的形式返回
        else:
            self.cursor = self.mysql.cursor()  # 指定每行数据以元祖的形式返回