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+
requests
librarydatasette
(version 0.65.1)sqlite3
(included with Python)geojson-to-sqlite
tooldatasette-geojson
plugin
-
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 \ --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 \
--static static:dev-locations/static \
-n tampa-dev-coord-db
This 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 50
Project structure:
dev-locations/
- Main directory containing database and configdev-locations/static/
- Static assets (CSS)script.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.