mirror of
https://github.com/ada-dmitry/lab6.git
synced 2026-09-24 01:10:15 +00:00
0.2
This commit is contained in:
Binary file not shown.
Binary file not shown.
+19
-8
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user