Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions data/questions.py
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand All @@ -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()
Expand Down