Используя Union all, получаю ошибку Replacement index 1 out of range for positional args tuple.
Мой код выглядит так:
columns = columns_list + [str(i) for i in request.form.getlist("columns")]
query = ("SELECT {} FROM raschett WHERE Наименование = ANY(%s) AND Месяц = ANY(%s) UNION ALL SELECT {} FROM rashet_station WHERE Наименование = ANY(%s) AND Месяц = ANY(%s);"
.format(",".join(["\"{}\"".format(c) for c in columns])))
rows = execute_query(query, (selected_stations, selected_indicators))
Для работы с БД использую psycopg2
Traceback (most recent call last):
File "C:\Users\antrodmi\AppData\Local\Programs\Python\Python311\Lib\site-packages\flask\app.py", line 2528, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\antrodmi\AppData\Local\Programs\Python\Python311\Lib\site-packages\flask\app.py", line 1825, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\antrodmi\AppData\Local\Programs\Python\Python311\Lib\site-packages\flask\app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\antrodmi\AppData\Local\Programs\Python\Python311\Lib\site-packages\flask\app.py", line 1799, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\antrodmi\Desktop\vesras\app.py", line 100, in ves1
.format(",".join(["\"{}\"".format(c) for c in columns])))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
IndexError: Replacement index 1 out of range for positional args tuple