mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-22 17:04:31 +02:00
Added Python library example to README
This commit is contained in:
parent
fad14ab943
commit
1a053d9438
1 changed files with 13 additions and 1 deletions
14
README.md
14
README.md
|
|
@ -14,7 +14,7 @@ Install it like this:
|
|||
|
||||
pip3 install sqlite-utils
|
||||
|
||||
Now you can do things like this:
|
||||
Now you can do things with the CLI utility like this:
|
||||
|
||||
$ sqlite-utils tables dogs.db --counts
|
||||
[{"table": "dogs", "count": 2}]
|
||||
|
|
@ -34,6 +34,18 @@ Now you can do things like this:
|
|||
1 4 Cleo
|
||||
2 2 Pancakes
|
||||
|
||||
Or you can import it and use it as a Python library like this:
|
||||
|
||||
```python
|
||||
import sqlite_utils
|
||||
db = sqlite_utils.Database("demo_database.db")
|
||||
# This line creates a "dogs" table if one does not already exist:
|
||||
db["dogs"].insert_all([
|
||||
{"id": 1, "age": 4, "name": "Cleo"},
|
||||
{"id": 2, "age": 2, "name": "Pancakes"}
|
||||
], pk="id")
|
||||
```
|
||||
|
||||
Full documentation: https://sqlite-utils.readthedocs.io/
|
||||
|
||||
Related projects:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue