Postgresql Check If Value Is String In Python