'Joining files using python and doing calculations without using pandas

I have two files user and transact need to use these files and get the below result and the catch is I cannot use pandas or any external libraries

**SELECT
t.transact_category_id,
sum(t.amnt) AS sum_amount,
count(DISTINCT t.user_id) AS num_users
FROM transact t
JOIN user u USING (user_id)
WHERE t.is_blocked = False
AND u.is_active = 1
GROUP BY t.transact_category_id
ORDER BY sum_amount DESC;**


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source