| 1 |
Getting started |
| 2 |
=============== |
| 3 |
|
| 4 |
.. _getting_started_demo: |
| 5 |
|
| 6 |
Play with a live demo |
| 7 |
--------------------- |
| 8 |
|
| 9 |
The best way to experience Datasette for the first time is with a demo: |
| 10 |
|
| 11 |
* `global-power-plants.datasettes.com <https://global-power-plants.datasettes.com/global-power-plants/global-power-plants>`__ provides a searchable database of power plants around the world, using data from the `World Resources Institude <https://www.wri.org/publication/global-power-plant-database>`__ rendered using the `datasette-cluster-map <https://github.com/simonw/datasette-cluster-map>`__ plugin. |
| 12 |
* `fivethirtyeight.datasettes.com <https://fivethirtyeight.datasettes.com/fivethirtyeight>`__ shows Datasette running against over 400 datasets imported from the `FiveThirtyEight GitHub repository <https://github.com/fivethirtyeight/data>`__. |
| 13 |
|
| 14 |
.. _getting_started_tutorial: |
| 15 |
|
| 16 |
Follow a tutorial |
| 17 |
----------------- |
| 18 |
|
| 19 |
Datasette has several `tutorials <https://datasette.io/tutorials>`__ to help you get started with the tool. Try one of the following: |
| 20 |
|
| 21 |
- `Exploring a database with Datasette <https://datasette.io/tutorials/explore>`__ shows how to use the Datasette web interface to explore a new database. |
| 22 |
- `Learn SQL with Datasette <https://datasette.io/tutorials/learn-sql>`__ introduces SQL, and shows how to use that query language to ask questions of your data. |
| 23 |
- `Cleaning data with sqlite-utils and Datasette <https://datasette.io/tutorials/clean-data>`__ guides you through using `sqlite-utils <https://sqlite-utils.datasette.io/>`__ to turn a CSV file into a database that you can explore using Datasette. |
| 24 |
|
| 25 |
.. _getting_started_datasette_lite: |
| 26 |
|
| 27 |
Datasette in your browser with Datasette Lite |
| 28 |
--------------------------------------------- |
| 29 |
|
| 30 |
`Datasette Lite <https://lite.datasette.io/>`__ is Datasette packaged using WebAssembly so that it runs entirely in your browser, no Python web application server required. |
| 31 |
|
| 32 |
You can pass a URL to a CSV, SQLite or raw SQL file directly to Datasette Lite to explore that data in your browser. |
| 33 |
|
| 34 |
This `example link <https://lite.datasette.io/?url=https%3A%2F%2Fraw.githubusercontent.com%2FNUKnightLab%2Fsql-mysteries%2Fmaster%2Fsql-murder-mystery.db#/sql-murder-mystery>`__ opens Datasette Lite and loads the SQL Murder Mystery example database from `Northwestern University Knight Lab <https://github.com/NUKnightLab/sql-mysteries>`__. |
| 35 |
|
| 36 |
.. _getting_started_codespaces: |
| 37 |
|
| 38 |
Try Datasette without installing anything with Codespaces |
| 39 |
--------------------------------------------------------- |
| 40 |
|
| 41 |
`GitHub Codespaces <https://github.com/features/codespaces/>`__ offers a free browser-based development environment that lets you run a development server without installing any local software. |
| 42 |
|
| 43 |
Here's a demo project on GitHub which you can use as the basis for your own experiments: |
| 44 |
|
| 45 |
`github.com/datasette/datasette-studio <https://github.com/datasette/datasette-studio>`__ |
| 46 |
|
| 47 |
The README file in that repository has instructions on how to get started. |
| 48 |
|
| 49 |
.. _getting_started_your_computer: |
| 50 |
|
| 51 |
Using Datasette on your own computer |
| 52 |
------------------------------------ |
| 53 |
|
| 54 |
First, follow the :ref:`installation` instructions. Now you can run Datasette against a SQLite file on your computer using the following command: |
| 55 |
|
| 56 |
:: |
| 57 |
|
| 58 |
datasette path/to/database.db |
| 59 |
|
| 60 |
This will start a web server on port 8001 - visit http://localhost:8001/ |
| 61 |
to access the web interface. |
| 62 |
|
| 63 |
Add ``-o`` to open your browser automatically once Datasette has started:: |
| 64 |
|
| 65 |
datasette path/to/database.db -o |
| 66 |
|
| 67 |
Use Chrome on OS X? You can run datasette against your browser history |
| 68 |
like so: |
| 69 |
|
| 70 |
:: |
| 71 |
|
| 72 |
datasette ~/Library/Application\ Support/Google/Chrome/Default/History --nolock |
| 73 |
|
| 74 |
The ``--nolock`` option ignores any file locks. This is safe as Datasette will open the file in read-only mode. |
| 75 |
|
| 76 |
Now visiting http://localhost:8001/History/downloads will show you a web |
| 77 |
interface to browse your downloads data: |
| 78 |
|
| •79 |
`Downloads table rendered by datasette <https://static.simonwillison.net/static/2017/datasette-downloads.png>`__ |
| 80 |
|
| 81 |
http://localhost:8001/History/downloads.json will return that data as |
| 82 |
JSON: |
| 83 |
|
| 84 |
:: |
| 85 |
|
| 86 |
{ |
| 87 |
"database": "History", |
| 88 |
"columns": [ |
| 89 |
"id", |
| 90 |
"current_path", |
| 91 |
"target_path", |
| 92 |
"start_time", |
| 93 |
"received_bytes", |
| 94 |
"total_bytes", |
| 95 |
... |
| 96 |
], |
| 97 |
"rows": [ |
| 98 |
[ |
| 99 |
1, |
| 100 |
"/Users/simonw/Downloads/DropboxInstaller.dmg", |
| 101 |
"/Users/simonw/Downloads/DropboxInstaller.dmg", |
| 102 |
13097290269022132, |
| 103 |
626688, |
| 104 |
0, |
| 105 |
... |
| 106 |
] |
| 107 |
] |
| 108 |
} |
| 109 |
|
| 110 |
http://localhost:8001/History/downloads.json?_shape=objects will return that data as |
| 111 |
JSON in a more convenient format: |
| 112 |
|
| 113 |
:: |
| 114 |
|
| 115 |
{ |
| 116 |
... |
| 117 |
"rows": [ |
| 118 |
{ |
| 119 |
"start_time": 13097290269022132, |
| 120 |
"interrupt_reason": 0, |
| 121 |
"hash": "", |
| 122 |
"id": 1, |
| 123 |
"site_url": "", |
| 124 |
"referrer": "https://www.dropbox.com/downloading?src=index", |
| 125 |
... |
| 126 |
} |
| 127 |
] |
| 128 |
} |