While working on a project that requires querying the Anki database directly outside of the Anki desktop application, I encountered an interesting issue with sqlite3
collations. This is is just a short post about how I went about registering a collation in order to execute SQL queries against the Anki db.
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z"/><line x1="12" y1="9" x2="12" y2="13"/><line x1="12" y1="17" x2="12.01" y2="17"/></svg>
</div>
<div class="callout-title-inner">CAUTION</div>
</div>
<div class="callout-content" >
Before you run anything that accesses the Anki database, you absolutely should backup your database first.
</div>
The problem
Let’s try a simple query. Open the Anki database: