Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documented the use of delete_where #630

Merged
merged 1 commit into from
Jul 18, 2024
Merged

Conversation

learning4life
Copy link
Contributor

@learning4life learning4life commented Jul 3, 2024

Documented the use of delete_where, as shown in #159


📚 Documentation preview 📚: https://sqlite-utils--630.org.readthedocs.build/en/630/

Documented the use of delete_where, as shown in simonw#159
@learning4life learning4life changed the title Documented the use of delete_where Documented the use of delete_where Jul 6, 2024
@learning4life
Copy link
Contributor Author

The example below shows why this doc update is needed using sqlite-utils v3.36:

Running the code in bash using docker

[root@b5441fc4c92e DockerSqliteUtils]# sqlite-utils insert global.db power_plants 'global_power_plant_database.csv' --csv
  [###################################-]   99%  00:00:00
[root@b5441fc4c92e DockerSqliteUtils]# python3
Python 3.9.19 (main, May 20 2024, 05:19:58) 
[GCC 8.5.0 20210514 (Red Hat 8.5.0-22)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite_utils
>>> db = sqlite_utils.Database("global.db")
>>> db["power_plants"].count_where("country > ?", [1])
33643
>>> db["power_plants"].delete_where()
<Table power_plants (country, country_long, name, gppd_idnr, capacity_mw, latitude, longitude, primary_fuel, other_fuel1, other_fuel2, other_fuel3, commissioning_year, owner, source, url, geolocation_source, wepp_id, year_of_capacity_data, generation_gwh_2013, generation_gwh_2014, generation_gwh_2015, generation_gwh_2016, generation_gwh_2017, generation_data_source, estimated_generation_gwh)>
>>> db["power_plants"].count_where("country > ?", [1])
0
>>> exit()
[root@b5441fc4c92e DockerSqliteUtils]# python3
Python 3.9.19 (main, May 20 2024, 05:19:58) 
[GCC 8.5.0 20210514 (Red Hat 8.5.0-22)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite_utils
>>> db = sqlite_utils.Database("global.db")
>>> db["power_plants"].count_where("country > ?", [1])
33643

@simonw
Copy link
Owner

simonw commented Jul 18, 2024

Thanks, I'll land this change but I'd like to fix this at source later on.

@simonw simonw merged commit 8964110 into simonw:main Jul 18, 2024
44 checks passed
simonw added a commit that referenced this pull request Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants