Я пытаюсь выдвинуть данные в postgres, используя понимание списка и morgify, но я получаю сообщение об ошибке.
на самом деле, сортировка - это словарь в следующем формате:
sort = {'forecast': [{'name': some_value, 'search_volume': some_int_value,
'competition': some_float_value}]}
data_text = ','.join(c.mogrify(
"(%(k)s,%(l['name'])s,l['search_volume'],l['competition'])",
l) for l in [v for k,v in sort.items()])
Ошибка:
Traceback (most recent call last):
File "/Users/lonewolf/PycharmProjects/seo_keyword_research_tools-master/keyword_expansion_tool.py", line 137, in get_lsi
expand(current_word)
File "/Users/lonewolf/PycharmProjects/seo_keyword_research_tools-master/keyword_expansion_tool.py", line 121, in expand
sorted_data = write_to_file(current_results, current_word)
File "/Users/lonewolf/PycharmProjects/seo_keyword_research_tools-master/keyword_expansion_tool.py", line 107, in write_to_file
l) for l in [v for k,v in sort.items()])
File "/Users/lonewolf/PycharmProjects/seo_keyword_research_tools-master/keyword_expansion_tool.py", line 107, in <genexpr>
l) for l in [v for k,v in sort.items()])
TypeError: list indices must be integers or slices, not str