Postgres String Operations In Python