How to store sqlite3 db file inside binary

84 Views Asked by At

What I want to do:

I am developing a CLI app which has a read-only database (sqlite using mattn/sqlite3) which should not be exposed and the binary is just an API over the read-only database.

I tried tools like packr but it gives File, string or []byte{} and the sqlx.Connect requires file path only

This statckoverflow question talks about using tempfile but that too stays on FS. I can't keep the DB file on FS as it can be accessed by anyone with access to the system.

What I have already tried

Keeping an encrypted file in storage and then decrypting it runtime and then storing it in sqlite in-memory db but when using multiple go-routines I'm facing a lot of issues like table not found which are already there on GH issues for mattn/sqlite3 repo and are unsolved. So, I can't work with in-memory database.

0

There are 0 best solutions below