SQLite functions to decode/encode fields in notes

d. german's Avatar

d. german

14 Aug, 2019 01:15 AM

hi everybody,

I developed a simple library of two UDFs for sqlite. They provide a way to decode a given field in a note, and to encode it too.


the functions anki_getfld(f, i) would take a "flds" column of the table notes and decode its i-th field.

For example, the following query will list the 2nd field of all the notes in the database:

select anki_getfld(flds, 2) from notes ;

Its complementary function is anki_setfld(f, index, newValue). Replaces the given field with another value. For example:

create temp table rip as
     select noteid, anki_setfld(flds, 10, "abc") as newfld from notes;

it does not allow to set the first field, since that would require a change in the checksum of the flds attribute, and there is no simple
way to guarantee that consistency.

With these two functions you can more easily extract and manipulate (including updating) the data in a given deck.
I warn you, you need to know the way the decks are stored in the database.

Comments are closed, but you can start a new discussion.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac