Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions chatgpt-python-api/README.md

This file was deleted.

9 changes: 0 additions & 9 deletions chatgpt-python-api/basic_chatgpt_call.py

This file was deleted.

24 changes: 0 additions & 24 deletions chatgpt-python-api/coding_assistant.py

This file was deleted.

38 changes: 0 additions & 38 deletions chatgpt-python-api/structured_output.py

This file was deleted.

5 changes: 0 additions & 5 deletions chatgpt-python-api/verify_setup.py

This file was deleted.

3 changes: 0 additions & 3 deletions geopandas-basics/README.md

This file was deleted.

1,165 changes: 0 additions & 1,165 deletions geopandas-basics/geopandas-basics.ipynb

This file was deleted.

3 changes: 0 additions & 3 deletions ollama-python-sdk/README.md

This file was deleted.

11 changes: 0 additions & 11 deletions ollama-python-sdk/chat.py

This file was deleted.

24 changes: 0 additions & 24 deletions ollama-python-sdk/chat_context.py

This file was deleted.

17 changes: 0 additions & 17 deletions ollama-python-sdk/generate_code.py

This file was deleted.

8 changes: 0 additions & 8 deletions ollama-python-sdk/generate_text.py

This file was deleted.

15 changes: 0 additions & 15 deletions ollama-python-sdk/streams.py

This file was deleted.

51 changes: 0 additions & 51 deletions ollama-python-sdk/tool_calling.py

This file was deleted.

40 changes: 40 additions & 0 deletions tinydb/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# TinyDB Tutorial Code (Real Python)

This repository contains the downloadable code for the Real Python tutorial: [TinyDB: A Lightweight JSON Database for Small Projects](https://realpython.com/tinydb-python/)

## Contents

<<<<<<< HEAD


create\_db.py - SCRIPT file containing code from the CREATE section of the tutorial.

read.py - REPL code file containing code from the READ section of the tutorial.

update\_db.py - SCRIPT file containing code from the UPDATE section of the tutorial.

update\_db\_v2.py - SCRIPT file containing code from the UPDATE section of the tutorial.

update\_db\_v3.py - SCRIPT file containing code from the UPDATE section of the tutorial.

delete.py - REPL code file containing code from the DELETE section of the tutorial.



countries\_file.csv - File containing csv data to be converted to TinyDB documents.

ten\_countries.json - File containing an existing JSON object representing ten TinyDB records in a countries table.



README.md - This file

=======
- `create.py` — All code from the **CREATE** section of the tutorial
- `read.py` — All code from the **READ** section of the tutorial
- `update.py` — All code from the **UPDATE** section of the tutorial
- `delete.py` — All code from the **DELETE** section of the tutorial
- `countries_file.csv` — CSV data used to create TinyDB documents
- `ten_countries.json` — Sample JSON file containing data for ten countries
- `README.md` — This file
>>>>>>> df2997f1b3bd2e296717c85dfa9ec8a08aaa2087
4 changes: 4 additions & 0 deletions tinydb/countries_file.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
location,population,continent
Argentina,45929925,South America
Switzerland,8990428,Europe
Mozambique,36147236,Africa
22 changes: 22 additions & 0 deletions tinydb/create_db.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from csv import DictReader

from tinydb import TinyDB

with TinyDB("countries.json", indent=4) as countries_db:
countries_table = countries_db.table(name="countries")

countries_table.insert({"location": "Vatican City", "population": 501})

countries_table.insert_multiple(
[
{"location": "India", "population": 1_417_492_000},
{"location": "China", "population": 1_408_280_000},
]
)

with open("countries_file.csv", "r") as csv_source:
reader = DictReader(csv_source)

for row in reader:
row["population"] = int(row["population"])
countries_table.insert(row)
22 changes: 22 additions & 0 deletions tinydb/delete.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# REPL code

from tinydb import TinyDB, where

countries_db = TinyDB("ten_countries.json")
countries_table = countries_db.table(name="countries")
len(countries_table)

countries_table.remove(doc_ids=[3, 5, 7])

len(countries_table)

countries_table.remove(where("population") < 300_000_000)
len(countries_table)

countries_table.truncate()
len(countries_table)

countries_db.tables()

countries_db.drop_table(name="countries")
countries_db.tables()
15 changes: 15 additions & 0 deletions tinydb/read.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# REPL Code

from pprint import pprint

from tinydb import Query, TinyDB

countries_db = TinyDB("ten_countries.json")
countries_table = countries_db.table(name="countries")
query = Query()
query_def = (query.population > 220_000_000) & (query.population < 250_000_000)
pprint(countries_table.search(query_def))
pprint(countries_table.search(query_def))
pprint(countries_table.search(query["% of world"] >= 17))
pprint(countries_table.get(doc_ids=[9, 10]))
countries_db.close()
Loading