https://simonwillison.net/2022/Jan/11/sqlite-utils/ Simon Willison's Weblog What's new in sqlite-utils sqlite-utils is my combined CLI tool and Python library for manipulating SQLite databases. Consider this the annotated release notes for sqlite-utils 3.20 and 3.21, both released in the past week. sqlite-utils insert --convert with --lines and --text The sqlite-utils insert command inserts rows into a SQLite database from a JSON, CSV or TSV file, creating a table with the necessary columns if one does not exist already. It gained three new options in v3.20: + sqlite-utils insert ... --lines to insert the lines from a file into a table with a single line column, see Inserting unstructured data with --lines and --text. + sqlite-utils insert ... --text to insert the contents of the file into a table with a single text column and a single row. + sqlite-utils insert ... --convert allows a Python function to be provided that will be used to convert each row that is being inserted into the database. See Applying conversions while inserting data, including details on special behavior when combined with --lines and --text. (#356) These features all evolved from an idea I had while re-reading my blog entry from last year, Apply conversion functions to data in SQLite columns with the sqlite-utils CLI tool. That blog entry introduced the sqlite-utils convert comand, which can run a custom Python function against a column in a table to convert that data in some way. Given a log file log.txt that looks something like this: 2021-08-05T17:58:28.880469+00:00 app[web.1]: measure#nginx.service= 4.212 request="GET /search/?type=blogmark&page=2&tag=highavailability HTTP/1.1" status_code=404 request_id= 25eb296e-e970-4072-b75a-606e11e1db5b remote_addr="10.1.92.174" forwarded_for="114.119.136.88, 172.70.142.28" forwarded_proto="http" via="1.1 vegur" body_bytes_sent=179 referer="-" user_agent="Mozilla/ 5.0 (Linux; Android 7.0;) AppleWebKit/537.36 (KHTML, like Gecko) Mobile Safari/537.36 (compatible; PetalBot;+https:// webmaster.petalsearch.com/site/petalbot)" request_time="4.212" upstream_response_time="4.212" upstream_connect_time="0.000" upstream_header_time="4.212"; I provided this example code to insert lines from a log file into a table with a single line column: cat log.txt | \ jq --raw-input '{line: .}' --compact-output | \ sqlite-utils insert logs.db log - --nl Since sqlite-utils insert requires JSON, this example first used jq to convert the lines into {"line": "..."} JSON objects. My first idea was to improve this with the new --lines option, which lets you replace the above with this: sqlite-utils insert logs.db log log.txt --lines Using --lines will create a table with a single lines column and import every line from the file as a row in that table. In the article, I then demonstrated how --convert could be used to convert those imported lines into structured rows using a regular expression: sqlite-utils convert logs.db log line --import re --multi "$(cat <