-
Notifications
You must be signed in to change notification settings - Fork 4
/
databaseOperationsPart4.py
31 lines (25 loc) · 1.05 KB
/
databaseOperationsPart4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
""" 28/12/2020 Database Connections
chinook.db dosyasını kendi dizinimize taşıdık ve üzerinden işlemler yapacağız.
"""
import sqlite3
connection = sqlite3.connect("chinook.db")
""" Aşağıdaki sorguda şehirlere göre gruplayarak en çok müşteri olan şehri ve müşteri sayısını buluyoruz.Azalan sırada getiriyoruz."""
"""
Select city,count(*)
from Customers
group by city
having count(*)>1
order by count(*) desc
"""
cursor = connection.execute("""Select city,count(*)
from Customers
group by city
having count(*)>1
order by count(*) desc
""")
for row in cursor:
print("City : "+row[0])
print("Count : "+str(row[1]))
print('*****************')
# connection ı kapatıyoruz.
connection.close()