예제 #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 get_add_shopify_ids(connection, table):
     with connection.cursor() as cur:
         cur.execute(f"SELECT shopify_id from {table}")
         results = cur.fetchall()
         return results
 def add_element(connection, table, elements):
     with connection.cursor() as cur:
         cur.execute(f"INSERT INTO {table} VALUES {elements};")
     connection.commit()
예제 #5
0
 def find_shopify_sku_sql(connection, table, sku):
     with connection.cursor() as cur:
         cur.execute(f"SELECT shopify_id from {table} WHERE sku = '{sku}'")
         results = cur.fetchall()
         return results