Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Datasette (CSVConf 2019)

Datasette (CSVConf 2019)

Datasette is a tool for instantly publishing structured data on the internet. It makes it easy to construct and execute arbitrary SQL queries (using SQLite) and export the results as CSV. It's accompanying tool csvs-to-sqlite makes it easy to convert CSV files into a SQLite database. More info at https://github.com/simonw/datasette

This talk presented at csv,conf,v4 in Portland on 9th May 2019

Simon Willison

May 09, 2019
Tweet

More Decks by Simon Willison

Other Decks in Programming

Transcript

  1. Some handy features • Filtering and faceting • Custom SQL

    queries • JSON API to everything • Export table (or query results) as CSV
  2. The secret sauce is SQLite • Small, fast, ubiquitous •

    A database is a single file • Doesn’t scale well for writes… • … but who cares if your data is read-only? • Ship your data and code in the same container!
  3. select "now" as nownext, * from talks where datetime("now", "-7

    hours") > datetime([datetime]) and datetime("now", "-7 hours") < datetime([datetime], "+30 minutes") union select "next" as nownext, * from talks where datetime(datetime("now", "-7 hours"), "+30 minutes") > datetime([datetime]) and datetime(datetime("now", "-7 hours"), "+30 minutes") < datetime([datetime], "+30 minutes") union select "later" as nownext, * from talks where datetime(datetime("now", "-7 hours"), "+60 minutes") < datetime([datetime]) order by [datetime] limit 12;
  4. https://csvconf-j7hipcg4aq-uc.a.run.app/csvconf-5ae783b?sql=select+ %22now%22+as+nownext%2C+*+from+talks+where%0D%0A+ +datetime%28%22now%22%2C+%22-7+hours%22%29+ %3E+datetime%28%5Bdatetime%5D%29+and%0D%0A+ +datetime%28%22now%22%2C+%22-7+hours%22%29+ %3C+datetime%28%5Bdatetime%5D%2C+ %22%2B30+minutes%22%29%0D%0Aunion+select+ %22next%22+as+nownext%2C+*+from+talks+where%0D%0A+ +datetime%28datetime%28%22now%22%2C+%22-7+hours%22%29%2C+ %22%2B30+minutes%22%29+

    %3E+datetime%28%5Bdatetime%5D%29+and%0D%0A+ +datetime%28datetime%28%22now%22%2C+%22-7+hours%22%29%2C+ %22%2B30+minutes%22%29+%3C+datetime%28%5Bdatetime%5D%2C+ %22%2B30+minutes%22%29%0D%0Aunion+select+ %22later%22+as+nownext%2C+*+from+talks+where%0D%0A+ +datetime%28datetime%28%22now%22%2C+%22-7+hours%22%29%2C+ %22%2B60+minutes%22%29+ %3C+datetime%28%5Bdatetime%5D%29%0D%0Aorder+by+ %5Bdatetime%5D+limit+12%3B Thank goodness for URL shorteners…