Skip to content

Instantly share code, notes, and snippets.

@simonw
Last active April 29, 2022 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonw/c61447d866f7f29d368183fb09d9bf41 to your computer and use it in GitHub Desktop.
Save simonw/c61447d866f7f29d368183fb09d9bf41 to your computer and use it in GitHub Desktop.

Datasette: a big bag of tricks for solving interesting problems using SQLite

Video: https://www.hytradboi.com/2022/datasette-a-big-bag-of-tricks-for-solving-interesting-problems-using-sqlite

CSV downloaded from from https://geodata.myfwc.com/datasets/myfwc::manatee-carcass-recovery-locations-in-florida/about

Commands run during the demo:

sqlite-utils insert manatees.db locations \
    Manatee_Carcass_Recovery_Locations_in_Florida.csv --csv

sqlite-utils schema manatees.db

sqlite-utils manatees.db "select * from locations limit 10"

sqlite-utils transform manatees.db locations \
  --rename LAT latitude \
  --rename LONG_ longitude \
  --type TLENGTH float \
  --drop created_user \
  --drop last_edited_user \
  --drop X \
  --drop Y \
  --drop STATE \
  --drop OBJECTID \
  --pk FIELDID

sqlite-utils convert manatees.db locations \
  REPDATE created_date last_edited_date \
  'r.parsedatetime(value)'

Further reading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment