Tune editor
This commit is contained in:
@@ -8,11 +8,10 @@ from .write import insert_tema
|
||||
|
||||
def create_db(con: Optional[Connection] = None):
|
||||
with get_connection(con) as con:
|
||||
drop_temes_table(con)
|
||||
create_temes_table(con)
|
||||
|
||||
for tema in data.TEMES:
|
||||
insert_tema(tema, con)
|
||||
# for tema in data.TEMES:
|
||||
# insert_tema(tema, con)
|
||||
|
||||
|
||||
def drop_temes_table(con: Connection):
|
||||
|
||||
@@ -40,7 +40,6 @@ def _get_tema_id_to_ngrams(con: Optional[Connection] = None) -> dict[int, model.
|
||||
query = """
|
||||
SELECT id, ngrams
|
||||
FROM temes
|
||||
WHERE hidden = 0
|
||||
"""
|
||||
with get_connection(con) as con:
|
||||
cur = con.cursor()
|
||||
|
||||
@@ -42,3 +42,16 @@ def update_tema(tema: model.Tema, con: Optional[Connection] = None):
|
||||
cur.execute(query, data)
|
||||
evict_tema_id_to_ngrams_cache()
|
||||
return
|
||||
|
||||
|
||||
def delete_tema(tema_id: int, con: Optional[Connection] = None):
|
||||
query = """
|
||||
DELETE FROM temes
|
||||
WHERE id = :id
|
||||
"""
|
||||
data = dict(id=tema_id)
|
||||
with get_connection(con) as con:
|
||||
cur = con.cursor()
|
||||
cur.execute(query, data)
|
||||
evict_tema_id_to_ngrams_cache()
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user