Exemplo n.º 1
0
def update_tires_shopify_tool(sku, new_price):
    connection = None
    try:
        # Make connection to database before starting
        connection = ShopifyToolsTires.make_connection()
        ShopifyToolsTires.update_tire_price(connection, "wheel_pros_tires",
                                            sku, new_price)
        #Now update in the database
        with connection.cursor() as cur:
            cur.execute(
                f"UPDATE wheel_pros_tires SET price={new_price} WHERE sku = '{sku}';"
            )
        connection.commit()

    except (Exception, psycopg2.Error) as error:
        print("Error while connecting to PostgreSQL", error)
    finally:
        if (connection):
            connection.close()
            print("PostgreSQL connection is closed")
 def remove_element(connection, table, element):
     with connection.cursor() as cur:
         cur.execute(f"DELETE FROM {table} WHERE shopify_id = '{element}'")
     connection.commit()
 def add_element(connection, table, elements):
     with connection.cursor() as cur:
         cur.execute(f"INSERT INTO {table} VALUES {elements};")
     connection.commit()