import psycopg2 def getcont(): connection = psycopg2.connect(host='localhost', dbname='dbdata', user='postgres', password='Q1w2e3r4') cursor = connection.cursor() cursor.execute('''SELECT * FROM public.parser''') arr = list(cursor.fetchall()) res = '' k = 0 while k != len(arr): i = arr[k] res = res + f'''

{i[1]}

Rate: {i[3]}

{i[2]}
''' k += 1 cursor.close() connection.close() return res