<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en-us" xmlns="http://www.w3.org/2005/Atom"><title>Simon Willison's Weblog: anton-zhiyanov</title><link href="http://simonwillison.net/" rel="alternate"/><link href="http://simonwillison.net/tags/anton-zhiyanov.atom" rel="self"/><id>http://simonwillison.net/</id><updated>2024-08-09T15:31:40+00:00</updated><author><name>Simon Willison</name></author><entry><title>High-precision date/time in SQLite</title><link href="https://simonwillison.net/2024/Aug/9/high-precision-datetime-in-sqlite/#atom-tag" rel="alternate"/><published>2024-08-09T15:31:40+00:00</published><updated>2024-08-09T15:31:40+00:00</updated><id>https://simonwillison.net/2024/Aug/9/high-precision-datetime-in-sqlite/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://antonz.org/sqlean-time/"&gt;High-precision date/time in SQLite&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Another neat SQLite extension from Anton Zhiyanov. &lt;code&gt;sqlean-time&lt;/code&gt; (&lt;a href="https://github.com/nalgeon/sqlean/tree/main/src/time"&gt;C source code here&lt;/a&gt;) implements high-precision time and date functions for SQLite, modeled after the design used by Go.&lt;/p&gt;
&lt;p&gt;A time is stored as a 64 bit signed integer seconds &lt;code&gt;0001-01-01 00:00:00 UTC&lt;/code&gt; - signed so you can represent dates in the past using a negative number - plus a 32 bit integer of nanoseconds - combined into a a 13 byte internal representation that can be stored in a BLOB column.&lt;/p&gt;
&lt;p&gt;A duration uses a 64-bit number of nanoseconds, representing values up to roughly 290 years.&lt;/p&gt;
&lt;p&gt;Anton includes dozens of functions for parsing, displaying, truncating, extracting fields and converting to and from Unix timestamps.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://lobste.rs/s/6mzz3c/high_precision_date_time_sqlite"&gt;lobste.rs&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/datetime"&gt;datetime&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/go"&gt;go&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/sqlite"&gt;sqlite&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/anton-zhiyanov"&gt;anton-zhiyanov&lt;/a&gt;&lt;/p&gt;



</summary><category term="datetime"/><category term="go"/><category term="sqlite"/><category term="anton-zhiyanov"/></entry><entry><title>Modern SQLite: Generated columns</title><link href="https://simonwillison.net/2024/May/8/modern-sqlite-generated-columns/#atom-tag" rel="alternate"/><published>2024-05-08T16:55:41+00:00</published><updated>2024-05-08T16:55:41+00:00</updated><id>https://simonwillison.net/2024/May/8/modern-sqlite-generated-columns/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://antonz.org/sqlite-generated-columns/"&gt;Modern SQLite: Generated columns&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
The second in Anton Zhiyanov's &lt;a href="https://antonz.org/tags/modern-sqlite/"&gt;series&lt;/a&gt; on SQLite features you might have missed.&lt;/p&gt;
&lt;p&gt;It turns out I had an incorrect mental model of generated columns. In SQLite these can be "virtual" or "stored" (written to disk along with the rest of the table, a bit like a materialized view). Anton noted that "stored are rarely used in practice", which surprised me because I thought that storing them was necessary for them to participate in indexes.&lt;/p&gt;
&lt;p&gt;It turns out that's not the case. Anton's example here shows a generated column providing indexed access to a value stored inside a JSON key:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;create table events (
  id integer primary key,
  event blob,
  etime text as (event -&amp;gt;&amp;gt; 'time'),
  etype text as (event -&amp;gt;&amp;gt; 'type')
);
create index events_time on events(etime);
insert into events(event) values (
  '{"time": "2024-05-01", "type": "credit"}'
);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt;: snej &lt;a href="https://lobste.rs/s/imyxxn/modern_sqlite_generated_columns#c_brqbyj"&gt;reminded me&lt;/a&gt; that this isn't a new capability either: SQLite has been able to create indexes on expressions for years.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://lobste.rs/s/imyxxn/modern_sqlite_generated_columns"&gt;lobste.rs&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/sqlite"&gt;sqlite&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/anton-zhiyanov"&gt;anton-zhiyanov&lt;/a&gt;&lt;/p&gt;



</summary><category term="sqlite"/><category term="anton-zhiyanov"/></entry><entry><title>redka</title><link href="https://simonwillison.net/2024/Apr/14/redka/#atom-tag" rel="alternate"/><published>2024-04-14T15:21:19+00:00</published><updated>2024-04-14T15:21:19+00:00</updated><id>https://simonwillison.net/2024/Apr/14/redka/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/nalgeon/redka"&gt;redka&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Anton Zhiyanov’s new project to build a subset of Redis (including protocol support) using Go and SQLite. Also works as a Go library.&lt;/p&gt;

&lt;p&gt;The guts of the SQL implementation are in the internal/sqlx folder.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://twitter.com/ohmypy/status/1779489065173467385"&gt;@ohmypy&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/go"&gt;go&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/redis"&gt;redis&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/sqlite"&gt;sqlite&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/anton-zhiyanov"&gt;anton-zhiyanov&lt;/a&gt;&lt;/p&gt;



</summary><category term="go"/><category term="redis"/><category term="sqlite"/><category term="anton-zhiyanov"/></entry><entry><title>SQLite 3.44: Interactive release notes</title><link href="https://simonwillison.net/2023/Nov/1/sqlite/#atom-tag" rel="alternate"/><published>2023-11-01T15:47:20+00:00</published><updated>2023-11-01T15:47:20+00:00</updated><id>https://simonwillison.net/2023/Nov/1/sqlite/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://antonz.org/sqlite-3-44/"&gt;SQLite 3.44: Interactive release notes&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Anton Zhiyanov compiled interactive release notes for the new release of SQLite, demonstrating several of the new features. I’m most excited about order by in aggregates—group_concat(name order by name desc)—which is something I’ve wanted in the past. Anton demonstrates how it works with JSON aggregate functions as well. The new date formatting options look useful as well.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/sqlite"&gt;sqlite&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/anton-zhiyanov"&gt;anton-zhiyanov&lt;/a&gt;&lt;/p&gt;



</summary><category term="sqlite"/><category term="anton-zhiyanov"/></entry><entry><title>sqlean.py: Python's sqlite3 with extensions</title><link href="https://simonwillison.net/2023/Jun/17/sqleanpy/#atom-tag" rel="alternate"/><published>2023-06-17T22:42:13+00:00</published><updated>2023-06-17T22:42:13+00:00</updated><id>https://simonwillison.net/2023/Jun/17/sqleanpy/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://antonz.org/sqlean-py/"&gt;sqlean.py: Python&amp;#x27;s sqlite3 with extensions&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Anton Zhiyanov built a new Python package which bundles a fresh, compiled copy of SQLite with his SQLean family of C extensions built right in. Installing it gets you the latest SQLite—3.42.0—with nearly 200 additional functions, including things like define() and eval(), fileio_read() and fileio_write(), percentile_95() and uuid4() and many more. “import sqlean as sqlite3” works as a drop-in replacement for the module from the standard library.


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/python"&gt;python&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/sqlite"&gt;sqlite&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/anton-zhiyanov"&gt;anton-zhiyanov&lt;/a&gt;&lt;/p&gt;



</summary><category term="python"/><category term="sqlite"/><category term="anton-zhiyanov"/></entry><entry><title>SQLime:  SQLite Playground</title><link href="https://simonwillison.net/2022/Jan/17/sqlime/#atom-tag" rel="alternate"/><published>2022-01-17T19:08:12+00:00</published><updated>2022-01-17T19:08:12+00:00</updated><id>https://simonwillison.net/2022/Jan/17/sqlime/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://sqlime.org/"&gt;SQLime:  SQLite Playground&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Anton Zhiyanov built this useful mobile-friendly online playground for trying things out it SQLite. It uses the sql.js library which compiles SQLite to WebAssembly, so it runs everything in the browser—but it also supports saving your work to Gists via the GitHub API. The JavaScript source code is fun to read: the site doesn’t use npm or Webpack or similar, opting instead to implement everything library-free using modern JavaScript modules and Web Components.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://twitter.com/simonw/status/1482845419637903366"&gt;Anton Zhiyanov&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/javascript"&gt;javascript&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/sqlite"&gt;sqlite&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/web-components"&gt;web-components&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/webassembly"&gt;webassembly&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/anton-zhiyanov"&gt;anton-zhiyanov&lt;/a&gt;&lt;/p&gt;



</summary><category term="javascript"/><category term="sqlite"/><category term="web-components"/><category term="webassembly"/><category term="anton-zhiyanov"/></entry><entry><title>sqlite-plus</title><link href="https://simonwillison.net/2021/Mar/25/sqlite-plus/#atom-tag" rel="alternate"/><published>2021-03-25T21:13:33+00:00</published><updated>2021-03-25T21:13:33+00:00</updated><id>https://simonwillison.net/2021/Mar/25/sqlite-plus/#atom-tag</id><summary type="html">
    
&lt;p&gt;&lt;strong&gt;&lt;a href="https://github.com/nalgeon/sqlite-plus/"&gt;sqlite-plus&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
Anton Zhiyanov bundled together a bunch of useful SQLite C extensions for things like statistical functions, unicode string normalization and handling CSV files as virtual tables. The GitHub Actions workflow here is a particularly useful example of compiling SQLite extensions for three different platforms.

    &lt;p&gt;&lt;small&gt;&lt;/small&gt;Via &lt;a href="https://antonz.org/sqlite-is-not-a-toy-database/"&gt;SQLite is not a toy database&lt;/a&gt;&lt;/small&gt;&lt;/p&gt;


    &lt;p&gt;Tags: &lt;a href="https://simonwillison.net/tags/sqlite"&gt;sqlite&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/github-actions"&gt;github-actions&lt;/a&gt;, &lt;a href="https://simonwillison.net/tags/anton-zhiyanov"&gt;anton-zhiyanov&lt;/a&gt;&lt;/p&gt;



</summary><category term="sqlite"/><category term="github-actions"/><category term="anton-zhiyanov"/></entry></feed>