SQLite constraint violation - How to insert data to this schema?
First, do you have any data in movies_genres?
SELECT * FROM movies_genres;

If not, you can check if the primary key is missing in any of the sources tables
SELECT movie_id FROM movies GROUP BY movie_id HAVING COUNT(1) &gt; 1;

and the same for genres. If above is ok, the error should not happen, but you can check with:
SELECT m.movie_id, g.genre_id 
FROM ( -- I assume the parentheses was a typo and moved it
    SELECT movie_id 
    FROM movies 
    WHERE title = arg1
) AS m
CROSS JOIN ( -- see comment above
    SELECT genre_id 
    FROM genres WHERE title = arg2
) AS g
GROUP BY m.movie_id, g.genre_id 
HAVING COUNT(1) &gt; 1;

You can btw simplify your query to:
SELECT m.movie_id, g.genre_id 
FROM movies m
JOIN genres g
    ON m.title = arg1  
   AND g.title = arg2