Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Datasette

Datasette is a tool for exploring and publishing data. It helps people take data of any shape, analyze and explore it, and publish it as an interactive website and accompanying API.
Datasette is aimed at data journalists, museum curators, archivists, local governments, scientists, researchers and anyone else who has data that they wish to share with the world. It is part of a wider ecosystem of 44 tools and 154 plugins dedicated to making working with structured data as productive as possible. [datasette.io]

Datasette是一个用于探索和发布数据的工具。它帮助人们处理任何形状的数据,进行分析和探索,并将其发布为互动网站及配套的API。
Datasette旨在服务于数据记者、博物馆策展人、档案管理员、地方政府、科学家、研究人员以及希望与全球分享数据的其他人。它是一个更广泛的生态系统的一部分,包括44个工具和154个插件,致力于使处理结构化数据的工作尽可能高效。 [datasette.io]

Data processing

pipx install sqlite-utils
sqlite-utils insert database.db table table.csv --csv
sqlite-utils drop-table database.db table
sqlite-utils enable-fts database.db table column_1 column_2
# sqlite-utils insert-files resource.db latex media/*.jpg

Selfhost

1

mkdir <dir>
cd <dir>
uv venv
.venv\Scripts\activate.bat
uv pip install datasette
uv pip install datasette-sitemap datasette-block-robots datasette-backup datasette-search-all datasette-external-links-new-tabs datasette-copyable datasette-publish-vercel
# datasette install datasette-render-images datasette-multiline-links datasette-render-markdown datasette-media
# datasette install git+https://github.com/next-LI/datasette-csv-importer.git
# uv pip install datasette-parquet 
datasette serve database.db
datasette serve database_1.db database_2.db -m metadata.yml

Deploy to Vercel

2

Create .github/workflows/vercel.yml

name: Deploy to Vercel
on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '18.x'
      - name: Install Vercel CLI
        run: npm i -g vercel
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.9'
      - name: Install dependencies
        run: pip install datasette datasette-sitemap datasette-block-robots datasette-backup datasette-search-all datasette-ripgrep datasette-render-images datasette-media datasette-render-markdown datasette-multiline-links datasette-external-links-new-tabs datasette-copyable datasette-publish-vercel
      - name: Deploy Datasette using Vercel
        env:
          VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
        run: |-
          datasette publish vercel database_1.db database_2.db \
            --metadata metadata.yml \
            --token $VERCEL_TOKEN \
            --project database

Vercel → Project database → Settings → Build and Deployment → Node.js Version → 18.x.

reference

resource

mark

extra

cache


  1. Metadata

  2. datasette-publish-vercel