Python CLI utility and library for manipulating SQLite databases https://sqlite-utils.datasette.io
  • Python 99.7%
  • C 0.2%
Find a file
Simon Willison 00c5a49a87 Option to ignore inserts if primary key exists already
Support for SQLite's INSERT OR IGNORE

In the API layer it looks like this:

    fresh_db["test"].insert({"id": 1, "bar": 3}, ignore=True)

For the CLI layer it looks like this:

    $ sqlite-utils insert data.db dogs dogs.json --ignore

Closes #21
2019-05-28 21:15:57 -07:00
docs Fixed RST syntax bug 2019-05-27 22:25:03 -07:00
sqlite_utils Option to ignore inserts if primary key exists already 2019-05-28 21:15:57 -07:00
tests Option to ignore inserts if primary key exists already 2019-05-28 21:15:57 -07:00
.gitignore Initial project layout + database table creation tools 2018-07-28 06:46:17 -07:00
.travis.yml Support for numpy types, closes #11 (#12) 2019-02-23 20:02:19 -08:00
LICENSE Added LICENSE file 2019-02-23 09:16:57 -08:00
README.md Link to my blog entry 2019-02-24 19:45:38 -08:00
setup.py Release 1.0.1 2019-05-27 17:50:28 -07:00

sqlite-utils

PyPI Travis CI Documentation Status License

Python CLI utility and library for manipulating SQLite databases.

Read more on my blog: sqlite-utils: a Python library and CLI tool for building SQLite databases

Install it like this:

pip3 install sqlite-utils

Now you can do things like this:

$ sqlite-utils tables dogs.db --counts
[{"table": "dogs", "count": 2}]

$ sqlite-utils dogs.db "select * from dogs"
[{"id": 1, "age": 4, "name": "Cleo"},
 {"id": 2, "age": 2, "name": "Pancakes"}]

$ sqlite-utils dogs.db "select * from dogs" --csv
id,age,name
1,4,Cleo
2,2,Pancakes

$ sqlite-utils dogs.db "select * from dogs" --table
  id    age  name
----  -----  --------
   1      4  Cleo
   2      2  Pancakes

Full documentation: https://sqlite-utils.readthedocs.io/

Related projects: