-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetmatsbystate.py
57 lines (32 loc) · 977 Bytes
/
getmatsbystate.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
47
48
49
50
51
52
53
54
55
56
import cx_Oracle
import sys
import os
if os.path.exists("statenums"):
os.remove("statenums")
else:
print("No results file here")
cx_Oracle.init_oracle_client(lib_dir="/usr/lib/oracle/21/client64/lib")
con = cx_Oracle.connect(user="boss", password="yogamats", dsn="adwyoga_low")
sys.stdout = open('statenums', 'w')
cur = con.cursor()
sql0 = "select count(distinct state) from jun2021yogadata"
cur.execute(sql0)
res = cur.fetchall()
total_records = (res[0][0])
#print(total_records, "Records Produced By Query")
cur.prefetchrows = total_records
cur.arraysize = total_records
#cur.execute(sql0)
#print()
#print()
#print(total_records)
#res = cur.fetchall()
sql1 = "select distinct state from jun2021yogadata order by state asc"
cur.execute(sql1)
res = cur.fetchall()
for x in res:
sql2 = "select count(*) from jun2021yogadata where state = :id"
cur.execute(sql2, id = x[0])
record = cur.fetchall()
print(record, x[0])
sys.stdout.close()