I think you want to look at the extension in [ext/misc/fileio.c](https://www.sqlite.org/src/artifact/9b69e25da3b51d4a). That same code is ensconced into recent sqlite3 shell tools, without need of loading an extension DLL. It does write/read files, converting from/to BLOB objects you can use with regular SQL. If you want to cutout the lives-in-a-file step, you might peruse the ``` sqlite3_blob_{open,read,write,close} ``` streaming interface. I've used it to good effect.