Skip to content

Instantly share code, notes, and snippets.

@denisdemaisbr
Created May 26, 2023 19:49
Show Gist options
  • Save denisdemaisbr/480603d57f50b572b3846939f0e450ed to your computer and use it in GitHub Desktop.
Save denisdemaisbr/480603d57f50b572b3846939f0e450ed to your computer and use it in GitHub Desktop.
sqlite3 insert or replace
-- insert or replace sqlite 3.x
create table config( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, key text, value text );
insert into config values (1, "fg", "#ff00ff" );
insert or replace into config(id, key, value) values ((select id from config where key = "bg"), "bg", "0x00ff00");
SELECT * FROM config;
$ sqlite3 < test.sql
SQLite version 3.34.0 2020-12-01 16:14:00
1|fg|#ff00ff
2|bg|0x00ff00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment