This commit is contained in:
ada-dmitry
2024-04-28 13:37:53 +03:00
parent 7cd1ab1f2e
commit 308b719963
6 changed files with 21 additions and 19 deletions
Binary file not shown.
Binary file not shown.
+19 -8
View File
@@ -13,14 +13,25 @@ class CathTable(DbTable):
def table_constraints(self):
return ['CONSTRAINT "Name" UNIQUE (cath_name)']
def find_by_position(self, num):
sql = "SELECT * FROM " + self.table_name()
sql += " ORDER BY "
sql += ", ".join(self.primary_key())
sql += " LIMIT 1 OFFSET %(offset)s"
def delete(self, val):
sql = "DELETE FROM " + self.table_name()
sql += " WHERE " + "".join(self.column_names_without_id())
sql += "=" + "'" + "".join(val) + "';"
cur = self.dbconn.conn.cursor()
cur.execute(sql, {"offset": num - 1})
cur.execute(sql)
self.dbconn.conn.commit()
def find_by_name(self, name):
cur = self.dbconn.conn.cursor()
sql_sel = "SELECT id FROM " + self.table_name()
sql_sel += " WHERE cath_name = " + "'" + name + "'" + ";"
cur.execute(sql_sel)
# sql = "SELECT * FROM " + self.table_name()
# sql += " ORDER BY "
# sql += ", ".join(self.primary_key())
# sql += " LIMIT 1 OFFSET %(offset)s"
# cur.execute(sql, {"offset": num - 1})
# print(cur)
return cur.fetchone()