Skip to content

One db per user #58

Discussion options

You must be logged in to vote

Let's say you want to achieve data isolation by having one sqlite db per user (already garbage warning hehe). How would you implement that in your code?

hey @andreas-cederved, good question. I don't think separating by one DB per user is a bad approach at all unless you have a ton of users. I think you can mostly isolate the separation within your SQLite implementation so the rest of your application doesn't need to know about it.

First, I'd make a map of accounts to *sql.DB objects here instead of just having one DB: https://github.com/benbjohnson/wtf/blob/main/sqlite/sqlite.go#L45

You'll also need to either have some way of separating accounts at the front end (e.g. subdomains like my…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@andreas-cederved
Comment options

Answer selected by benbjohnson
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants