Postgres Get Number Of Columns In Python For All Selected Lines