From 3df15fb2f790cdf34ed1839de906c06326f63e62 Mon Sep 17 00:00:00 2001 From: melercg Date: Sun, 12 Apr 2026 02:18:34 +0300 Subject: [PATCH] feat: add SQL queries for questions 1-10 --- data/questions.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/data/questions.py b/data/questions.py index f2c74f6..5b7a0f1 100644 --- a/data/questions.py +++ b/data/questions.py @@ -1,7 +1,7 @@ import psycopg2 ## Bu değeri localinde çalışırken kendi passwordün yap. Ama kodu pushlarken 'postgres' olarak bırak. -password = 'postgres' +password = '1234' def connect_db(): conn = psycopg2.connect( @@ -16,7 +16,7 @@ def connect_db(): def question_1_query(): connection = connect_db() cursor = connection.cursor() - cursor.execute('') + cursor.execute('SELECT customer_name, country FROM customers ;') data = cursor.fetchall() cursor.close() connection.close() @@ -26,7 +26,7 @@ def question_1_query(): def question_2_query(): connection = connect_db() cursor = connection.cursor() - cursor.execute('') + cursor.execute('SELECT * FROM orders ORDER BY total_amount DESC LIMIT 5;') data = cursor.fetchall() cursor.close() connection.close() @@ -36,7 +36,7 @@ def question_2_query(): def question_3_query(): connection = connect_db() cursor = connection.cursor() - cursor.execute('') + cursor.execute('SELECT product_name,price FROM productS ORDER BY price ASC LIMIT 3;') data = cursor.fetchall() cursor.close() connection.close() @@ -46,7 +46,7 @@ def question_3_query(): def question_4_query(): connection = connect_db() cursor = connection.cursor() - cursor.execute('') + cursor.execute('SELECT *FROM customers ORDER BY signup_Date ASC LIMIT 10;') data = cursor.fetchall() cursor.close() connection.close() @@ -56,7 +56,7 @@ def question_4_query(): def question_5_query(): connection = connect_db() cursor = connection.cursor() - cursor.execute('') + cursor.execute('SELECT product_name,stock_quantity FROM products ORDER BY stock_quantity DESC LIMIT 1;') data = cursor.fetchall() cursor.close() connection.close() @@ -66,7 +66,7 @@ def question_5_query(): def question_6_query(): connection = connect_db() cursor = connection.cursor() - cursor.execute('') + cursor.execute('SELECT * FROM orders ORDER BY order_date DESC LIMIT 1;') data = cursor.fetchall() cursor.close() connection.close() @@ -76,7 +76,7 @@ def question_6_query(): def question_7_query(): connection = connect_db() cursor = connection.cursor() - cursor.execute('') + cursor.execute('SELECT product_name FROM products ORDER BY product_name ASC;') data = cursor.fetchall() cursor.close() connection.close() @@ -86,7 +86,7 @@ def question_7_query(): def question_8_query(): connection = connect_db() cursor = connection.cursor() - cursor.execute('') + cursor.execute('SELECT customer_id ,email FROM customers ORDER BY customer_id ASC LIMIT 5;') data = cursor.fetchall() cursor.close() connection.close() @@ -96,7 +96,7 @@ def question_8_query(): def question_9_query(): connection = connect_db() cursor = connection.cursor() - cursor.execute('') + cursor.execute('SELECT order_id, total_amount FROM orders ORDER BY total_amount ASC LIMIT 3;') data = cursor.fetchall() cursor.close() connection.close() @@ -106,7 +106,7 @@ def question_9_query(): def question_10_query(): connection = connect_db() cursor = connection.cursor() - cursor.execute('') + cursor.execute('SELECT * FROM customers WHERE country = 'Turkey' ORDER BY customer_name ASC;') data = cursor.fetchall() cursor.close() connection.close()