Postgres Use Variable In Soql Substring Method In Python