def create_shell(data): """ Db shells : Create Shell """ query = 'INSERT INTO shells(shell_id, vision, thought, tag_name, created) VALUES(?, ?, ?, ?, ?);' cur = conn.cursor() cur.execute(query, data) conn.commit() return cur.lastrowid
def delete_shell_search(id_): """ Db shells_search : Delete Shell Search """ query = f'DELETE FROM shells_search WHERE shell_id=?;' cur = conn.cursor() cur.execute(query, [id_]) conn.commit() return cur.lastrowid
def create_shell_search(data): """ Db shells_search : Save entry to Shell Search """ query = 'INSERT INTO shells_search(vision, thought, shell_id) VALUES(?, ?, ?);' cur = conn.cursor() cur.execute(query, data) conn.commit() return cur.lastrowid
def update_shell_search(id_, vision, thought): """ Db shells_search : Update Shell Search """ query = f'UPDATE shells_search SET vision=?, thought=? WHERE shell_id=?;' cur = conn.cursor() cur.execute(query, (vision, thought, id_)) conn.commit() return cur.lastrowid
def delete_shell_by_tag_name(name): """ Db shells : Delete Shell """ query = f'DELETE FROM shells WHERE tag_name="{name}";' cur = conn.cursor() cur.execute(query) conn.commit() return cur.lastrowid
def delete_shell(id): """ Db shells : Delete Shell """ query = f'DELETE FROM shells WHERE shell_id="{id}";' cur = conn.cursor() cur.execute(query) conn.commit() return cur.lastrowid
def update_shell(id_, vision, thought, tag): """ Db shells : Update Shell """ query = f'UPDATE shells SET vision=?, thought=?, tag_name=?, created=? WHERE shell_id=?;' cur = conn.cursor() cur.execute(query, (vision, thought, tag, datetime.now(), id_)) conn.commit() return cur.lastrowid
def update_shell_update_tag_to_default(tag_name, updated_name='default'): """ Db shells : Update Shell """ query = f'UPDATE shells SET tag_name="{updated_name}" WHERE tag_name="{tag_name}";' cur = conn.cursor() cur.execute(query) conn.commit() return cur.lastrowid
def create_tag(data): """ Db tags : Create Tag """ query = 'INSERT INTO tags(tag_id, tag_name) VALUES(?, ?);' cur = conn.cursor() cur.execute(query, data) conn.commit() return cur.lastrowid
def delete_shell_search_by_tag_name(name): """ Db shells_search : Delete Shell Search """ query = ''' DELETE FROM shells_search WHERE shell_id IN ( SELECT shell_id FROM shells WHERE tag_name=? ); ''' cur = conn.cursor() cur.execute(query, [name]) conn.commit() return cur.lastrowid