Closed learning4life closed 5 days ago
The example below shows why this doc update is needed using sqlite-utils
v3.36:
[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
Thanks, I'll land this change but I'd like to fix this at source later on.
Documented the use of delete_where, as shown in https://github.com/simonw/sqlite-utils/issues/159
📚 Documentation preview 📚: https://sqlite-utils--630.org.readthedocs.build/en/630/