There is a request in postgressql, it displays several columns with information, among which there is a column "id", it contains id as numbers. It is required to go through the cycle on this column, and when meeting the id, output id to the line first, and then the remaining columns. I wrote such a code, but I think it would be more correct to check not for emptiness, but for a number and build it in ascending order.

result = CreateRecordFormat() result.AddInt32("id") result.AddRecordSet("ОстальныеДанныеКiD") # sql-это сам запрос к базе res = SqlQuery(sql, id, ПерваяНеделя, ПоследняяНеделя ) CreateRecordSet(result) for rec in res: if rec is not None: result["id"].From(res) 
  • "contains id as numbers" - what type? array? And what driver do you use? psycopg2? - FeroxTL
  • "думаю правильнее было бы проверить не на пустоту, а на число и выстроить по возрастанию" - why do it on the client, when it can be done on the DB side faster and more efficiently? - MaxU

0