为什么执行查询后表没有发生变化。没有psycopg2信息,在表中查询后或显示IDLE/console时价格没有变化
def connect_to_database(self):
try:
self.conn = psycopg2.connect(**self.db_params)
print("Connected to database.")
revert to connector.
except (exception, psycopg2.Error) as an error:
print(f"Error connecting to PostgreSQL: {error}")
not return
def foo(self):
condition = self.query_text_field.get("1.0", "end-1c")
query = f"""
UPDATE PRODUCTS
Installation price = price* 0.9
{condition}; # condition = 'WHERE "group" = "Bakery"'
SELECT * FROM PRODUCTS
"""
self.cursor.execute(query)
self.conn.commit()
result = self.cursor.fetchall()
我找到了解决办法,我在查询中使用单引号而不是双引号来指定列名