# Функция для замены NULL на пустые строки
def replace_null_with_empty_string(conn):
    cursor = conn.cursor()
    query = """
        UPDATE contacts
        SET 
            name = COALESCE(name, ''),
            phone = COALESCE(phone, ''),
            email = COALESCE(email, ''),
            vk_id = COALESCE(vk_id, ''),
            chat_id = COALESCE(chat_id, ''),
            ws_st = COALESCE(ws_st, ''),
            ws_stop = COALESCE(ws_stop, ''),
            web_st = COALESCE(web_st, ''),
            fin_prog = COALESCE(fin_prog, ''),
            b_city = COALESCE(b_city, ''),
            b_fin = COALESCE(b_fin, ''),
            b_ban = COALESCE(b_ban, ''),
            b_ign = COALESCE(b_ign, ''),
            b_baners = COALESCE(b_baners, ''),
            b_butt = COALESCE(b_butt, ''),
            b_mess = COALESCE(b_mess, ''),
            orders = COALESCE(orders, '{}'),
            curator = COALESCE(curator, ''),
            bonus = COALESCE(bonus, ''),
            shop_status = COALESCE(shop_status, ''),
            answers = COALESCE(answers, ''),
            quiz = COALESCE(quiz, ''),
            kassa = COALESCE(kassa, ''),
            gc_url = COALESCE(gc_url, ''),
            key_pr = COALESCE(key_pr, ''),
            n_con = COALESCE(n_con, ''),
            canal = COALESCE(canal, ''),
            data_on = COALESCE(data_on, ''),
            data_t = COALESCE(data_t, ''),
            utm_source = COALESCE(utm_source, ''),
            utm_medium = COALESCE(utm_medium, ''),
            utm_campaign = COALESCE(utm_campaign, ''),
            utm_term = COALESCE(utm_term, ''),
            utm_content = COALESCE(utm_content, ''),
            gcpc = COALESCE(gcpc, '')
    """
    cursor.execute(query)
    conn.commit()