Skip to content

Instantly share code, notes, and snippets.

@divinity76
Created December 12, 2025 18:21
Show Gist options
  • Select an option

  • Save divinity76/e2e06b5929ed55939acb02c75ae2d342 to your computer and use it in GitHub Desktop.

Select an option

Save divinity76/e2e06b5929ed55939acb02c75ae2d342 to your computer and use it in GitHub Desktop.
SQLlite rant
SQLite is kinda shite at handling programmer errors.
If you store music blobs as TEXT or STRING or even just a typo in BLOB,
you will get silent corruption, like missing null bytes.
Be very careful to actually add the datatype `BLOB` to anything containing binary data.
Furthermore, SQLite CLI is a piece of shit when it comes to handling binary data.
I have complained to the SQLite developers about it,
and they just shrug it off as "no can fix, would require massive refactor of the sqlite cli"
look at this shit:
```
sqlite> CREATE TABLE wtf(val STRING);
sqlite> INSERT into WTF values('0123');
sqlite> SELECT * FROM wtf;
123
```
- sqlite corrupted `0123` into `123` because i accidentally wrote `val STRING` instead of `val TEXT`
now look at this shit:
```
$ sqlite3 wtf.db3
SQLite version 3.45.1 2024-01-30 16:01:20
Enter ".help" for usage hints.
sqlite> CREATE TABLE wtf2(val BLOB);
sqlite> INSERT INTO wtf2 VALUES(X'000000');
sqlite> .exit
$ sqlite3 wtf.db3 'SELECT * FROM wtf2' | wc -c
1
$ php -r 'echo ((new PDO("sqlite:wtf.db3"))->query("SELECT * FROM wtf2")->fetch()[0]);' | wc -c
3
```
sqlite3 cli corrupted 3 null bytes into... 1 newline.
I had to resort to PHP to get the bytes safely out of the database, sqlite cli cannot do it.
(TODO: add rant here about how sqlite's QUOTE() function is broken)
SQLite is great for many things, but has several of these footguns :(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment