def init_db(db_alias): #2、初始数据化信息,通过配置 db_info = ConfigYaml().get_db_conf_info(db_alias) host = db_info["db_host"] user = db_info["db_user"] password = db_info["db_password"] name = db_info["db_name"] #3、初始化myssql对象 conn = Mysql(host, user, password, name) print(conn) return conn
def init_db(db_alias): # 2、初始数据化信息,通过配置 db_info = ConfigYaml().get_db_conf_info(db_alias) host = db_info["db_host"] user = db_info["db_user"] password = db_info["db_password"] db_name = db_info["db_name"] charset = db_info["db_charset"] port = int(db_info["db_port"]) # 3、初始化mysql对象 conn = Mysql(host, user, password, db_name, charset, port) return conn
def init_db(db_alias): # 2、初始化数据信息,通过配置 db_info = ConfigYaml().get_db_conf_info(db_alias) host = db_info['db_host'] user = db_info['db_user'] password = db_info['db_password'] db_name = db_info['db_name'] charset = db_info['db_charset'] port = int(db_info['db_port']) # 3、初始化mysql对象 conn = Mysql(host, user, password, db_name, charset, port) # print(conn) return conn
def init_db(db_alias): # 通过读取配置文件,初始化数据库信息 db_info = ConfigYaml().get_db_conf_info(db_alias) host = db_info["db_host"] user = db_info["db_user"] password = db_info["db_password"] db_name = db_info["db_name"] charset = db_info["db_charset"] port = int(db_info["db_port"]) # 初始化Mysql对象 conn = Mysql(host, user, password, db_name, charset, port) print(conn) return conn
def init_db(db_alias): #2、初始化数据信息、通过配置 db_info = ConfigYaml().get_db_conf_info(db_alias) host = db_info["db_host"] user = db_info["db_user"] password = db_info["db_password"] db_name = db_info["db_name"] charset = db_info["db_charset"] port = int(db_info["db_port"]) # "7090"是一个字符串,故要转换int类型 # port = db_info["db_port"] #3、初始化mysql对象 conn = Mysql(host,user,password,db_name,charset ,port ) print(conn) return conn
def init_db(db_alias): db_info = Conf.ConfigYaml().get_db_config_info(db_alias) # 2、初始化数据库信息,通过配置 host = db_info["db_host"] user = db_info["db_user"] password = db_info["db_password"] name = db_info["db_name"] charset = db_info["db_charset"] port = int(db_info["db_port"]) # 3、初始化mysql对象 conn = Mysql(host, user, password, name, charset, port) # print(conn) return conn
def init_db(db_alias): """ 初始化配置文件,并初始化mysql对象 :param db_alias: :return: """ db_info = ConfigYml().get_db_conf_info(db_alias) host = db_info["db_host"] user = db_info["db_user"] password = db_info["db_password"] db_name = db_info["db_name"] charset = db_info["db_charset"] port = int(db_info["db_port"]) conn = Mysql(host, user, password, db_name, charset, port) return conn
def init_db(db_alias): db_init = ConfigYaml().get_db_conf_info(db_alias) host = db_init.get('host', '127.0.0.1') port = int(db_init.get('port', 3306)) user = db_init.get('user') database = db_init.get('database') password = db_init.get('password') charset = db_init.get('charset', 'utf8') conn = Mysql(host=host, port=port, user=user, password=password, database=database, charset=charset) return conn
def init_db(db_alise): # 初始化数据库配置信息 db_info = ConfigYaml().get_db_config_info(db_alise) host = db_info["db_host"] user = db_info["db_user"] port = int(db_info["db_port"]) password = db_info["db_password"] database = db_info["db_database"] charset = db_info["db_charset"] # 初始化数据库游标对象 conn = Mysql(host=host, user=user, password=password, database=database, charset=charset, port=port) return conn
def init_db(db_alias): # db_1: # db_host: "127.0.0.1" # bd_user: "******" # db_password: "******" # bd_database: "test_27" # db_charset: "utf8" # db_port: "3306" #初始化数据信息 通过配置 db_info = ConfigYaml().get_db_conf_info(db_alias) host = db_info["db_host"] user = db_info["bd_user"] password = db_info["db_password"] database = db_info["bd_database"] charset = db_info["db_charset"] port = int(db_info["db_port"]) #port需要转为int类型 #初始化mysql对象 conn = Mysql(host, user, password, database, charset, port) print(conn) return conn