Postgresql Invalid Input Value Python 3 Mathematical Functions