fix(unique)_func_insert

This commit is contained in:
ada-dmitry
2024-04-28 13:09:24 +03:00
parent 57de47d41a
commit ae3cbeed26
4 changed files with 8 additions and 5 deletions
Binary file not shown.
+5 -2
View File
@@ -64,8 +64,11 @@ class DbTable:
sql += ", ".join(self.column_names_without_id()) + ") VALUES("
sql += ", ".join(vals) + ")"
cur = self.dbconn.conn.cursor()
cur.execute(sql)
self.dbconn.conn.commit()
try:
cur.execute(sql)
self.dbconn.conn.commit()
except psycopg2.errors.UniqueViolation:
self.dbconn.conn.rollback()
return
def first(self):
+3 -3
View File
@@ -117,7 +117,7 @@ class Main:
else:
return next_step
def show_add_cath(self):
def add_cath(self):
data = []
data.append(input("Введите название (1 - отмена): ").strip())
if data[0] == "1":
@@ -131,7 +131,7 @@ class Main:
data[0] = input("Название не может быть пустым! Введите название заново (1 - отмена):").strip()
if data[0] == "1":
return
CathTable().insert_one(data)
CathTable().insert_one(data)
return
def show_dish_in_cath(self):
@@ -178,7 +178,7 @@ class Main:
elif current_menu == "2":
self.show_main_menu()
elif current_menu == "3":
self.show_add_cath()
self.add_cath()
current_menu = "1"
print("До свидания!")
return
Binary file not shown.