Mistři v programování na #hovnokod

Python #474

def mac_search(*args):
    db = MySQLdb.connect(host="localhost",user="test",passwd="test",db="test")
    cursor = db.cursor()
    cursor.execute('SELECT * FROM ip_groups WHERE mac="%s" AND is_deleted=0;' %args[0].split()[0])
    for j in cursor.fetchall():
        cursor.execute("SELECT * FROM iptraffic_service_links WHERE ip_group_id=%s and is_deleted=0;" %j[1])
        for j1 in cursor.fetchall():
            cursor.execute("SELECT * FROM service_links WHERE id=%s AND is_deleted=0;" %j1[0])
            for j2 in cursor.fetchall():
                cursor.execute("SELECT * FROM accounts WHERE is_deleted=0 AND id=%s AND is_blocked=0;" %j2[2])
                for j3 in cursor.fetchall():
                    cursor.execute("SELECT * FROM service_links WHERE account_id=%s AND is_deleted=0;" %j2[2])
                    for j4 in cursor.fetchall():
                        if j4[3]==465 or j4[3]==641:
                            cursor.execute("SELECT * FROM s_multicast WHERE service_id=%s AND %s>=ip_start AND %s<=ip_end;" %(j4[3],args[0].split()[1],args[0].split()[1]))
                            for j5 in cursor.fetchall():
                                return j5

HovnoKod,