I have figured it out. When I started flicd through /etc/rc.local it was running as root with no environmental variables, and the data of the buttons was stored in the root directory. When I ran the exact same command as user pi, the environmental variables were set, PATH, USER etc. The fix was simple: use full path names for the data base file.
My apologies for wasting your time when the error was mine.