Reputation: 3260
I'm writing an application that uses an SQLite database to save state between different runs of the program. Most of this state follows a repetitive structure and fits nicely into SQL's relational model. However, there are a few pieces of state that represent global values having to do with user configuration, one-offs that don't make a lot of sense to put into a table.
Is there a standard way to handle such information through SQLite, or RDMSes in general?
Upvotes: 1
Views: 752
Reputation: 3611
Try a simple table of key-value-pairs like this:
CREATE TABLE IF NOT EXISTS settings (key TEXT, value TEXT)
And then you can insert records that link variables with names like:
INSERT INTO settings (key, value) VALUES ('bg_color', 'red')
Then you can leave it to your app to query this table and apply the settings in a context-specific manner.
Upvotes: 4