From f98d1fdb24f9166ce571e6242b3ac2fb91ae6e61 Mon Sep 17 00:00:00 2001
From: henningxtro <henning.sextro@gmail.com>
Date: Sun, 16 May 2021 23:48:13 +0200
Subject: [PATCH] Fixed string concatenation for sql statement in
 getProductLinksForProduct

---
 Crawler/api.py | 1 -
 Crawler/sql.py | 6 +++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/Crawler/api.py b/Crawler/api.py
index 0779b45..890c39c 100644
--- a/Crawler/api.py
+++ b/Crawler/api.py
@@ -2,7 +2,6 @@ from flask import Flask
 from flask_restful import Resource, Api, reqparse
 
 import crawler
-import sql
 
 app = Flask(__name__)
 api = Api(app)
diff --git a/Crawler/sql.py b/Crawler/sql.py
index 1cf3a58..ed81741 100644
--- a/Crawler/sql.py
+++ b/Crawler/sql.py
@@ -35,7 +35,7 @@ def getProductsForVendor(vendor_id: int) -> [{}]:
     conn = __getConnection__()
     cur = conn.cursor()
 
-    query = 'SELECT product_id, url FROM product_links WHERE vendor_id = %s'
+    query = 'SELECT product_id, url FROM product_links WHERE vendor_id = %s' % vendor_id
 
     cur.execute(query, (vendor_id,))
 
@@ -53,8 +53,8 @@ def getProductLinksForProduct(product_id: int) -> [dict]:
     conn = __getConnection__()
     cur = conn.cursor()
 
-    query = 'SELECT vendor_id, url FROM product_links WHERE product_id = %s'
-
+    query = 'SELECT vendor_id, url FROM product_links WHERE product_id = %s' % product_id
+    print(query)
     cur.execute(query, (product_id,))
 
     products = list(map(lambda x: {'product_id': product_id, 'vendor_id': x[0], 'url': x[1]}, cur.fetchall()))