Я пытаюсь запустить следующий оператор обновления с помощью psycopg2:
class AddPathToHTMLFile(ConnectToPostgres):
"""
This class is used to add to each mission's row the HTML file after a retrieve function has occurred on an object.
So the user could return to that mission again without RePlotting.
"""
@classmethod
def set_query(cls, mission_name):
path = get_file_path(mission_name)
try:
query = f'UPDATE {FIND_SECOND_GDT} SET "HTMLFile" = {str(path)} WHERE "MissionName" = "{mission_name}"'
cls.cursor.execute(query)
# Commit the insertion of data.
cls.connection.commit()
count = cls.cursor.rowcount
print(count, f"Record inserted successfully into {FIND_SECOND_GDT} table")
except (Exception, psycopg2.Error) as error:
if cls.connection:
print("Failed to insert data.", error)
# Class: ConnectToPostgres Establishes connection to the DB and been tested to work.
class ConnectToPostgres:
"""
Class that Connects to the PostgreSQL DB.
"""
connection = psycopg2.connect(user=POSTGRESQL_CONNECTION['user'],
password=POSTGRESQL_CONNECTION['password'],
host=POSTGRESQL_CONNECTION['host'],
port=POSTGRESQL_CONNECTION['port'],
database=POSTGRESQL_CONNECTION['database'])
cursor = connection.cursor()
При запуске кода я получаю следующую ошибку:
Failed to insert data. syntax error at or near "/"
LINE 1: UPDATE find_second_gdt SET "HTMLFile" = /home/yovel/PycharmP...
Поэтому я попытался поставить путь в двойных кавычках, но тогда ошибка изменилась:
path = "/home/yovel/PycharmProjects/Triangulation-Calculator/triangulationapi/syria2.html"
Failed to insert data. relation "find_second_gdt" does not exist
LINE 1: UPDATE find_second_gdt SET "HTMLFile" = "/home/yovel/Pycharm...