The reason I have posted this in python help is because I suspect this to be a problem on psycopg2 side or the way I am using it. I am running same thing in golang and it works fine.
It works with single query ofcourse, but I want to run it in 2 phases to be sure about the behaviour of python.