Git Product home page Git Product logo

datasette-ics's Introduction

datasette-ics

PyPI Changelog Tests License

Datasette plugin that adds support for generating iCalendar .ics files with the results of a SQL query.

Installation

Install this plugin in the same environment as Datasette to enable the .ics output extension.

$ pip install datasette-ics

Usage

To create an iCalendar file you need to define a custom SQL query that returns a required set of columns:

  • event_name - the short name for the event
  • event_dtstart - when the event starts

The following columns are optional:

  • event_dtend - when the event ends
  • event_duration - the duration of the event (use instead of dtend)
  • event_description - a longer description of the event
  • event_uid - a globally unique identifier for this event
  • event_tzid - the timezone for the event, e.g. America/Chicago

A query that returns these columns can then be returned as an ics feed by adding the .ics extension.

Demo

This SQL query calculates the lowest tide per day at Pillar Point in Half Moon Bay, California.

Since the query returns event_name, event_dtstart and event_tzid columns it produces this ICS feed. If you subscribe to that in a calendar application such as Apple Calendar you get something that looks like this:

Apple Calendar showing low tides at Pillar Point during a week

Using a canned query

Datasette's canned query mechanism can be used to configure calendars. If a canned query definition has a title that will be used as the title of the calendar.

Here's an example, defined using a metadata.yaml file:

databases:
  mydatabase:
    queries:
      calendar:
        title: My Calendar
        sql: |-
          select
            title as event_name,
            start as event_dtstart,
            description as event_description
          from
            events
          order by
            start
          limit
            100

This will result in a calendar feed at http://localhost:8001/mydatabase/calendar.ics

datasette-ics's People

Contributors

simonw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

introt

datasette-ics's Issues

Put calendar title in X-WR-CALNAME

The iCalendar standard doesn't provide anywhere for the title of the calendar, but it looks like most software (Google Calendar, iCalendar, Outlook at least) supports X-WR-CALNAME. Needed for #3.

Figure out how to support timezones

Everything is in UTC at the moment. Need to work out how to allow users to specify the timezone of each event such that the resulting iCalendar file is correct.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.