-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-yogamats_sold_md.py
46 lines (25 loc) · 1.04 KB
/
get-yogamats_sold_md.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import sys
import cx_Oracle
import os
if os.path.exists("yogamatssold"):
os.remove("yogamatssold")
print("File removed.")
else:
print("No yogamatssold file here")
cx_Oracle.init_oracle_client(lib_dir="/usr/lib/oracle/21/client64/lib")
con = cx_Oracle.connect(user="curious", password="access*SOL", dsn="adw-xyz")
sys.stdout = open('yogamatssold', 'w')
cur = con.cursor()
sql0 = "select count(*) from jun2021yogadata where state = 'MD' and age_yrs BETWEEN 30 and 50"
cur.execute(sql0)
count = cur.fetchone()
print(count, "Total mats sold in MD")
sql1 = "select count(*) from jun2021yogadata where state = 'MD' and age_yrs BETWEEN 30 and 50 and sex = 'F'"
cur.execute(sql1)
count1 = cur.fetchone()
print(count1, "Total mats sold to women between ages 30 and 50")
sql2 = "select count(*) from jun2021yogadata where state = 'MD' and age_yrs BETWEEN 30 and 50 and sex = 'M'"
cur.execute(sql2)
count2 = cur.fetchone()
print(count2, "Total mats sold to men between ages 30 and 50")
sys.stdout.close