-
Notifications
You must be signed in to change notification settings - Fork 0
/
reset_odd_even.py
35 lines (31 loc) · 1.2 KB
/
reset_odd_even.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
import datetime, sys
from sqlalchemy import Table, Column, Integer, String, MetaData, create_engine,\
Float, update
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QMessageBox, QApplication
def odd_even(message):
msg = QMessageBox()
msg.setStyleSheet("font: 10pt Arial; color: black; background-color: gainsboro")
msg.setWindowIcon(QIcon('./images/logos/logo.jpg'))
msg.setIcon(QMessageBox.Information)
msg.setText(message)
msg.setWindowTitle('Reset parameter')
msg.exec_()
try:
metadata = MetaData()
params = Table('params', metadata,
Column('paramID', Integer(), primary_key=True),
Column('item', String),
Column('value', Float))
engine = create_engine('postgresql+psycopg2://postgres@localhost/catering')
con = engine.connect()
myear = int(str(datetime.date.today())[0:4])
updeven = update(params).where(params.c.paramID == 4).values(value = int(myear%2))
con.execute(updeven)
message = "Reset parameter successful!"
except:
message = "Reset parameter failed"
app = QApplication(sys.argv)
app.setStyle("Windows")
sys.exit(odd_even(message))
app.exec_()