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
+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):