This repository uses a Python script to import data from the City of Tampa's ArcGIS GeoJSON endpoint into a SQLite database for viewing with Datasette.
- Python 3.11+
requestslibrarydatasette(version 0.65.2 — latest stable; a 1.0 upgrade needs the template fork and metadata config redone, see Theming)sqlite3(included with Python)geojson-to-sqlitetooldatasette-geojsonplugin
-
Install dependencies:
pip install -r requirements.txt
-
Set up Python version:
echo "3.11" > .python-version
-
Run the script:
python script.py
The script will:
- Fetch GeoJSON from Tampa's ArcGIS endpoint
- Update SQLite database in
dev-locations/locations.db - Archive removed records with timestamp
- Convert Unix timestamps to ISO format
-
Run Datasette locally:
datasette dev-locations/locations.db -m dev-locations/metadata.json \ --template-dir dev-locations/templates \ --setting suggest_facets off --setting default_page_size 50 \ --static static:dev-locations/static
Deploy to Heroku:
datasette publish heroku dev-locations/locations.db \
--metadata dev-locations/metadata.json \
--template-dir dev-locations/templates \
--static static:dev-locations/static \
-n tampa-dev-coord-dbThis repository uses GitHub Actions to:
- Run the script daily at midnight UTC
- Commit database changes to the repository
- Deploy the updated database to Heroku
The workflow file .github/workflows/update-data.yml handles:
- Scheduled runs
- Manual triggers
- Updates when code is pushed to main
- Deployment to Heroku with proper configuration
The database contains these components:
current_full- Complete table with all fields (hidden from public view)archived_full- Archive of removed records (hidden from public view)current- Public view with renamed columns and sensitive data removedarchived- Public view of archived records
Key fields include:
RECORDID(Primary Key)- Location data:
ADDRESS,UNIT,geometry(GeoJSON Point) - Status data:
APPSTATUS,TENTATIVEHEARING,TENTATIVETIME - Type information:
RECORDALIAS(displayed as "Type") - Metadata:
CREATEDDATE,LASTUPDATE(ISO format) - For archived records:
archived_date
The dev-locations/metadata.json file configures:
- Database title and description
- Table display options
- Custom facets
- CSS styling
- Table permissions
Configure Datasette with environment variables or the --setting flag:
datasette dev-locations/locations.db --setting suggest_facets off --setting default_page_size 50The site is themed to match The Tampa Monitor's design
system. ~/Sites/tm-static is the source of truth; shared CSS and fonts are copied
in verbatim (never hand-edited here) by a sync script:
node scripts/sync-design.js # copy anything that drifted from tm-static
node scripts/sync-design.js --check # report drift without writing (exit 1 if any)How it fits together:
dev-locations/templates/- forkedbase.htmlwraps every Datasette page in the Monitor chrome (_monitor_header.html,_monitor_footer.html);index.htmlis a custom homepage. Activated by the--template-dirflag (Procfile + commands above).dev-locations/static/css/site.css- the stylesheet entry point. It imports Datasette's ownapp.cssinto the lowest cascade layer so the synced design-system layers (andtheme.css) can override it; the stock unlayeredapp.csslink is removed in the forkedbase.html. Don't re-add it.dev-locations/static/css/theme.css- the only hand-edited CSS file: all dev-coord-specific styling (Datasette UI retheme, homepage). It must stay the last import insite.css.- Everything else under
static/css/andstatic/fonts/is a pristine synced copy.
Project structure:
dev-locations/- Main directory containing database and configdev-locations/templates/- Custom Datasette templates (Monitor chrome + homepage)dev-locations/static/css/,dev-locations/static/fonts/- Design system (synced from tm-static, see Theming)scripts/sync-design.js- One-way design-system sync from tm-staticscript.py- Main data processing scriptProcfile- Defines Heroku web process
Temporary files:
temp.geojson- Deleted after import
Code is licensed under MIT. Data sourced from City of Tampa Open Data.