Python and AI
Python 3.12 was announced today, some interesting features:
function reminded me that I need
to internalize itertools and use it more often. The
function is especially handy.
PES-701 - Changes to
: * quote reuse is a good
one. You don’t have to hunt for different types of quotes. You can use
double-quote inside the
without having to use
single-quote or escape it. Huge UX improvement. * f-strings can now be
multi-line, which makes it easy to read * f-strings are parsed with PEG
parser leading to precise error messages.
Andrew Ng: Opportunities in AI - 2023 - Youtube Video.
Updating SQLite table with new values when values exist
Scenario: when two different processes update a SQLite table.
Schema of the table under consideration:
CREATE TABLE sitecache ( PRIMARY KEY, url STRING title STRING, generator STRING, published datetime, updated datetime, author string, description string, kind string, keywords TEXT,html text);
Let’s assume process
updates columns -
The first insert looks like:
insert or replace into sitecache(url, title, html) values(?,?,?)
the second insert to update the rest is the interesting part:
WITH new (title, generator, published, updated, author, description, kind, keywords, html)INSERT OR REPLACE INTO sitecache(title, generator, published, updated, author, description, kind, keywords, html)SELECT old.url, new.title, new.generator, new.published, new.updated, new.author, new.description, new.kind, new.keywords, new.html FROM new LEFT JOIN sitecache AS old on new.url = old.url
Inspired by this answer - Source: Stackoverflow .