示例#1
0
def update_db_v_4_3_2_1(**kwargs):
    con, cur = get_cur()
    groups = ''
    sql = """ select id from `groups` """
    try:
        cur.execute(sql)
    except sqltool.Error as e:
        funct.out_error(e)
    else:
        groups = cur.fetchall()

    for g in groups:
        sql = """
		INSERT  INTO settings (param, value, section, `desc`, `group`) values('haproxy_enterprise', '0', 'haproxy', 'Use this option, if your HAProxy is enterprise. It change service name for rebooting/reloading', '%s');
		""" % g[0]
        try:
            cur.execute(sql)
            con.commit()
        except sqltool.Error as e:
            if kwargs.get('silent') != 1:
                if e.args[
                        0] == 'columns param, group are not unique' or e == " 1060 (42S21): columns param, group are not unique ":
                    pass
                else:
                    print("An error occurred:", e)
        else:
            print("Updating... groups")
    cur.close()
    con.close()
示例#2
0
def update_db_v_4_5_1(**kwargs):
    con, cur = get_cur()

    sql = """ select name from role where name  = 'superAdmin';"""
    try:
        cur.execute(sql)
    except sqltool.Error as e:
        funct.out_error(e)
    else:
        role = cur.fetchall()

    if not role:
        sql = list()
        sql.append("update role set name = 'superAdmin' where id = '1';")
        sql.append(
            "update role set name = 'admin', `description` = 'Has access everywhere except the Admin area' where id = '2';"
        )
        sql.append("update role set id = '4' where id = '3';")
        sql.append(
            "INSERT  INTO role (id, name, `description`) values('3', 'editor', 'Has the same as the admin except the Servers page');"
        )
        sql.append("update user set role = 'superAdmin' where role = 'admin';")
        sql.append("update user set role = 'admin' where role = 'editor';")
        for i in sql:
            try:
                cur.execute(i)
                con.commit()
            except sqltool.Error as e:
                pass
        else:
            if kwargs.get('silent') != 1:
                print('DB was update to 4.5.0')
    cur.close()
    con.close()
示例#3
0
def update_db_v_4_5_8_2(**kwargs):
	con, cur = get_cur()
	groups = ''
	sql = """ select id from `groups` """
	try:
		cur.execute(sql)
	except sqltool.Error as e:
		funct.out_error(e)
	else:
		groups = cur.fetchall()

	for g in groups:
		sql = """
		INSERT  INTO settings (param, value, section, `desc`, `group`) values('maxmind_key', '', 'haproxy', 'License key for downloading to GeoLite2 DB. You can create it on maxmind.com', '%s');
		""" % g[0]
		try:
			cur.execute(sql)
			con.commit()
		except sqltool.Error as e:
			if kwargs.get('silent') != 1:
				if e.args[0] == 'columns param, group are not unique' or e == " 1060 (42S21): columns param, group are not unique ":
					pass
				else:
					print("An error occurred:", e)
		else:
			print("Updating... groups")
	cur.close()
	con.close()