The Datasette Ecosystem¶
Datasette sits at the center of a growing ecosystem of open source tools aimed at making it as easy as possible to gather, analyze and publish interesting data.
These tools are divided into two main groups: tools for building SQLite databases (for use with Datasette) and plugins that extend Datasette's functionality.
Tools for creating SQLite databases¶
csvs-to-sqlite lets you take one or more CSV files and load them into a SQLite database. It can also extract repeated columns out into a separate table and configure SQLite full-text search against the contents of specific columns.
sqlite-utils is a Python library and CLI tool that provides shortcuts for loading data into SQLite. It can be used programmatically (e.g. in a Jupyter notebook) to load data, and will automatically create SQLite tables with the necessary schema.
The CLI tool can consume JSON streams directly and use them to create tables. It can also be used to query SQLite databases and output the results as CSV or JSON.
db-to-sqlite is a CLI tool that builds on top of SQLAlchemy and allows you to connect to any database supported by that library (including MySQL, oracle and PostgreSQL), run a SQL query and save the results to a new table in a SQLite database.
You can mirror an entire database (including copying foreign key relationships) with the
$ db-to-sqlite --all "postgresql://simonw@localhost/myblog" blog.db
markdown-to-sqlite reads Markdown files with embedded YAML metadata (e.g. for Jekyll Front Matter) and creates a SQLite table with a schema matching the metadata. This is useful if you want to keep structured data in text form in a GitHub repository and use that to build a SQLite database.
geojson-to-sqlite converts GeoJSON files to SQLite, optionally using SpatiaLite to create geospatial indexes for fast geometric queries.
shapefile-to-sqlite converts ESRI shapefiles to SQLite, optionally using SpatiaLite .
socrata2sql is a tool by Andrew Chavez at the Dallas Morning News. It works with Socrata, a widely used platform for local and national government open data portals. It uses the Socrata API to pull down government datasets and store them in a local SQLite database (it can also export data to PostgreSQL, MySQL and other SQLAlchemy-supported databases).
For example, to create a SQLite database of the City of Dallas Payment Register you would run the following command:
$ socrata2sql insert www.dallasopendata.com 64pp-jeba
Datasette's plugin system makes it easy to enhance Datasette with additional functionality.
datasette-graphql provides a GraphQL interface for querying the data contained in your Datasette instance.
datasette-cluster-map is the original Datasette plugin, described in Datasette plugins, and building a clustered map visualization.
The plugin works against any table with latitude and longitude columns. It can load over 100,000 points onto a map to visualize the geographical distribution of the underlying data.
datasette-auth-github adds an authentication layer to Datasette. Users will have to sign in using their GitHub account before they can view data or interact with Datasette. You can also use it to restrict access to specific GitHub users, or to members of specified GitHub organizations or teams.
datasette-auth-tokens provides a mechanism for creating secret API tokens that can then be used with Datasette's Authentication and permissions system. These tokens can be hard-coded into the plugin configuration or the plugin can be configured to access tokens stored in a SQLite database table.
datasette-permissions-sql lets you configure Datasette permissions checks to use custom SQL queries, which means you can make permisison decisions based on data contained within your databases.
datasette-upload-csvs allows users to upload CSV files directly into a Datasette instance through their web browser.
datasette-json-html renders HTML in Datasette's table view driven by JSON returned from your SQL queries. This provides a way to embed images, links and lists of links directly in Datasette's main interface, defined using custom SQL statements.
datasette-atom can output Datasette query results as Atom feeds, suitable for subscribing to using a feed reader application.
datasette-ics can output query results as an iCalendar feed, suitable for subscribing to from calendar software such as Google Calendar or Apple Calendar.
datasette-init allows you to define tables and views in your metadata file that should be created on startup if they do not already exist.
datasette-write provides an interface at
/-/write allowing users to execute SQL write queries against a selected database.
datasette-media adds the ability to serve media files such as images directly, configured through a SQL query that maps a URL parameter to a path to a file on disk. It can also serve resized image thumbnails.
datasette-jellyfish exposes custom SQL functions for a range of common fuzzy string matching functions, including soundex, porter stemming and levenshtein distance. It builds on top of the Jellyfish Python library.
datasette-doublemetaphone by Matthew Somerville adds custom SQL functions for applying the Double Metaphone fuzzy "sounds like" algorithm.
datasette-render-images works with SQLite tables that contain binary image data in BLOB columns. It converts any images it finds into
data-uri image elements, allowing you to view them directly in the Datasette interface.
datasette-render-binary renders binary data in a slightly more readable fashion: it shows ASCII characters as they are, and shows all other data as monospace octets. Useful as a tool for exploring new unfamiliar databases as it makes it easier to spot if a binary column may contain a decipherable binary format.
datasette-render-markdown adds tools for rendering Datasette rows that are formatted using Markdown.
datasette-render-html lets you configure columns that contain HTML from trusted sources such that the HTML is rendered correctly within the Datasette interface.
datasette-pretty-json seeks out JSON values in Datasette's table browsing interface and pretty-prints them, making them easier to read.
datasette-haversine provides a SQL
haversine() function which can calculate the haversine distance between two geographical points. You can then sort by this distance to find records closest to a specified location.
select haversine(lat1, lon1, lat2, lon2, 'mi');
datasette-bplist provides tools for working with Apple's binary plist format embedded in SQLite database tables. If you use OS X you already have dozens of SQLite databases hidden away in your
~/Library folder that include data in this format - this plugin allows you to view the decoded data and run SQL queries against embedded values using a
bplist_to_json(value) custom SQL function.
fetch() calls to the JSON API provided by your Datasette instance.
datasette-mask-columns allows you to use
metadata.json to configure specific table columns that should be masked - that should return null no matter what value is contained within the column. This is useful for things like hiding
password columns from public display.