I don't know python but try using one insert instead of two for person. Also why do you have have person_id in the person table when you can use the id of that table person.id?
Insert pet info first, then get the pet id of that insert then insert person info with one insert, you don't need two person id fields.
INSERT INTO pet (id, name, breed, age, dead) VALUES (0, "Fluffy", "Unicorn", 1000, 0);
get id of pet insert and assign var
$pet_id = id
INSERT INTO person(id, first_name, last_name, age) VALUES(0, "Zed", "Shaw", 37, '$pet_id');