This release introduces the new sqlite-utils convert command (#251) and corresponding table.convert(...) Python method (#302). These tools can be used to apply a Python conversion function to one or more columns of a table, either updating the column in place or using transformed data from that column to populate one or more other columns.
This command-line example uses the Python standard library textwrap module to wrap the content of the content column in the articles table to 100 characters:
$ sqlite-utils convert content.db articles content\
'"\n".join(textwrap.wrap(value, 100))'\
--import=textwrap
The same operation in Python code looks like this:
import sqlite_utils, textwrap
db = sqlite_utils.Database("content.db")
db["articles"].convert("content", lambda v: "\n".join(textwrap.wrap(v, 100)))See the full documentation for the sqlite-utils convert command and the table.convert(...) Python method for more details.
Also in this release:
- The new
table.count_where(...)method, for counting rows in a table that match a specific SQLWHEREclause. (#305) - New
--silentoption for the sqlite-utils insert-files command to hide the terminal progress bar, consistent with the--silentoption forsqlite-utils convert. (#301)