At the first look its seems correct to me but Postgresql was refusing it at every attempt. After studying the complete code with keen detail , I got to know about the actual bug When SQLAlchemy ...