cursor.execute(f'insert into free_drink_list_config (drink_id, label, price) values ({free_drink_list_config["drink"]["id"]}, "{free_drink_list_config["label"]}", {free_drink_list_config["price"]})')
self.db.connection.commit()
returnself.get_free_drink_list_configs()
exceptExceptionaserr:
traceback.print_exc()
self.db.connection.rollback()
raiseDatabaseExecption("Something went wrong with Database: {}".format(err))
defget_free_drink_list_types(self):
try:
cursor=self.db.connection.cursor()
cursor.execute('select * from free_drink_list_type')
returncursor.fetchall()
exceptExceptionaserr:
traceback.print_exc()
self.db.connection.rollback()
raiseDatabaseExecption("Something went wrong with Database: {}".format(err))
defget_free_drink_list_types_for_drink(self,id):
try:
cursor=self.db.connection.cursor()
cursor.execute(f'select a.* from free_drink_list_type a, free_drink_list_type_config b where free_drink_list_config_id={id} and b.free_drink_list_type_id=a.id')
returncursor.fetchall()
exceptExceptionaserr:
traceback.print_exc()
self.db.connection.rollback()
raiseDatabaseExecption("Something went wrong with Database: {}".format(err))
defget_free_drink_list_type(self,name):
try:
cursor=self.db.connection.cursor()
iftype(name)==str:
sql=f'select * from free_drink_list_type where name={name}'
eliftype(name)==int:
sql=f'select * from free_drink_list_type where id={name}'
else:
raiseDatabaseExecption("name as no type int or str. name={}, type={}".format(name,type(name)))
cursor.execute(sql)
returncursor.fetchone()
exceptExceptionaserr:
traceback.print_exc()
self.db.connection.rollback()
raiseDatabaseExecption("Something went wrong with Database: {}".format(err))