Rails Postgres String Operations In Python