generated from BYUIDSS/blank_project_repository
-
Notifications
You must be signed in to change notification settings - Fork 1
/
measurement.py
28 lines (21 loc) · 1.04 KB
/
measurement.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
import pandas as pd
class measurement:
def __init__(self, cvcursor, cvconn):
self.cvcursor = cvcursor
self.cvconn = cvconn
def insert_measurement(self, measurement):
self.cvcursor.execute('INSERT INTO measurement (measurement_name) VALUES (%s)', (measurement,))
self.cvconn.commit()
def select_measurement(self):
self.cvcursor.execute("SELECT * FROM measurement")
return self.cvcursor.fetchall()
def display_measurement(self):
df = pd.DataFrame(self.select_measurement())
df.columns = ['Measurement Id', 'Measurement']
return df
def update_measurement(self, measurement_id, measurement):
self.cvcursor.execute('UPDATE measurement SET measurement_name = %s WHERE measurement_id = %s', (measurement, measurement_id))
self.cvconn.commit()
def delete_measurement(self, measurement_id):
self.cvcursor.execute('DELETE FROM measurement WHERE measurement_id = %s', (measurement_id,))
self.cvconn.commit()