-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathescholDBIntf.py
34 lines (24 loc) · 1.01 KB
/
escholDBIntf.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
import creds
import mysql.connector
########################################
#
# Gets the series, group info from eschol DB
#
########################################
class escholDB:
queryUnits = "SELECT attrs->>'$.elements_id', id elements_id FROM units WHERE attrs->>'$.elements_id' is not null"
def __init__(self):
print("connect to eschol DB here")
self.cnxn = mysql.connector.connect(user=creds.escholDB.username,
password=creds.escholDB.password,
host=creds.escholDB.server,
database=creds.escholDB.database,
port=creds.escholDB.port)
self.cursor = self.cnxn.cursor()
def getUnits(self):
print("read all the Elements related groups")
self.cursor.execute(self.queryUnits)
groupSeries = {}
for row in self.cursor:
groupSeries[str(row[0],'utf-8')] = row[1]
return groupSeries