generated from BYUIDSS/blank_project_repository
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcolor.py
27 lines (21 loc) · 888 Bytes
/
color.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
import pandas as pd
class color:
def __init__(self, cvcursor, cvconn):
self.cvcursor = cvcursor
self.cvconn = cvconn
def insert_color(self, color):
self.cvcursor.execute('INSERT INTO color (color_name) VALUES (%s)', (color,))
self.cvconn.commit()
def select_color(self):
self.cvcursor.execute('SELECT * FROM color')
return self.cvcursor.fetchall()
def display_color(self):
df = pd.DataFrame(self.select_color())
df.columns = ['Color Id', 'Color']
return df
def update_color(self, color_id, color):
self.cvcursor.execute('UPDATE color SET color_name = %s WHERE color_id = %s', (color, color_id))
self.cvconn.commit()
def delete_color(self, color_id):
self.cvcursor.execute('DELETE FROM color WHERE color_id = %s', (color_id,))
self.cvconn.commit()