Sql Set And Replace Last Character On Number Of Rows Python