These are the steps I used to take a csv file and turn it into browsable database for free using Datasette and Heroku . The data used is parking infraction data from the City of Waterloo Open Data .
Create a new directory and set up a python virtual environment. Download the data from here and save it in the directory as waterloo_parking_infractions.csv.
Install the Datasette and csvs-to-sqlite packages:
pip install datasette
pip install csvs-to-sqlite
Convert the csv file to an sqlite database:
csvs-to-sqlite waterloo_parking_infractions.csv waterloo_parking_infractions.db
To run locally, run this command:
datasette serve waterloo_parking_infractions.db
You can then open a browser and go to http://127.0.0.1:8001 to browse the database.
To publish using Heroku, create an account and install the Heroku CLI :
Create a metadata.json file in the directory. This is optional, but allows us to display some information on the dataset we are sharing.
{
"title": "City of Waterloo Bylaw Parking Infractions",
"description": "Contains records pertaining to parking infractions within the City of Waterloo. Details of each infraction including date, street name, and issued fine are included.",
"source": "City of Waterloo Open Data",
"source_url": "https://opendata-city-of-waterloo.opendata.arcgis.com/datasets/city-of-waterloo-bylaw-parking-infractions"
}
Publish to Heroku. For more information see the docs here :
datasette publish heroku waterloo_parking_infractions.db -n waterloo-parking-infractions -m metadata.json --extra-options="--config sql_time_limit_ms:5500"
View in browser here
Now you can run SQL queries on the database in the browser. Here are a few sample queries.
All in all, this makes for a quick free way to set up to do some exploratory analysis and easily share it with anyone.