Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ghuntley committed Dec 7, 2021
0 parents commit 248b8d6
Show file tree
Hide file tree
Showing 10 changed files with 246 additions and 0 deletions.
Empty file added .data/.gitkeep
Empty file.
132 changes: 132 additions & 0 deletions .gitignore
@@ -0,0 +1,132 @@
# Datasette
.data/data.db

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
14 changes: 14 additions & 0 deletions .gitpod.yml
@@ -0,0 +1,14 @@
ports:
- port: 3000
onOpen: open-preview

tasks:
- init: |
./install.sh
command: |
sudo apt-get install entr
ls *.csv *.json *.sh | entr -r ./start.sh
vscode:
extensions:
- ms-python.python
21 changes: 21 additions & 0 deletions LICENSE
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 Gitpod

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
47 changes: 47 additions & 0 deletions README.md
@@ -0,0 +1,47 @@
# A Datasette template on Gitpod

This is a [Datasette](https://datasette.io/) template configured for ephemeral development environments on [Gitpod](https://www.gitpod.io/).

## Next Steps

Click the button below to start a new development environment:

[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/gitpod-io/template-datasette)

## Get Started With Your Own Project

### A new project

Click the above "Open in Gitpod" button to start a new workspace. Once you're ready to push your first code changes, Gitpod will guide you to fork this project so you own it.

### An existing project

To get started with Datasette on Gitpod, add a [`.gitpod.yml`](./.gitpod.yml) file which contains the configuration to improve the developer experience on Gitpod. To learn more, please see the [Getting Started](https://www.gitpod.io/docs/getting-started) documentation.

## Notes & caveats

Drag and drop any CSV files you like to this project root and they will be converted into a SQLite database and loaded into a Datasette instance.

You can uncomment lines in `requirements.txt` to install extra plugins.

## Configuring full-text search

Datasette supports SQLite full-text search. You can configure it for a table using the `sqlite-utils` command-line tool.

In the terminal run the following:

```bash
$ cd .data
$ sqlite-utils tables data.db --table --columns
table columns
------- ------------------------------------
example ['headline', 'body', 'url', 'extra']
```

This shows you the tables and columns in your database.

If you want to make the `example` table searchable by `headline` and `body`, run the following command:

$ sqlite-utils enable-fts data.db example headline body --fts4

Your Datasette instance will now display a search box that can be used to search the text in those columns.
2 changes: 2 additions & 0 deletions example.csv
@@ -0,0 +1,2 @@
headline,body,url
This is an example,To try this out open,https://gitpod.io#https://github.com/gitpod-io/template-datasette
6 changes: 6 additions & 0 deletions install.sh
@@ -0,0 +1,6 @@
pip3 install -U -r requirements.txt --user && \
rm .data/data.db || true && \
for f in *.csv
do
sqlite-utils insert .data/data.db ${f%.*} $f --csv
done
4 changes: 4 additions & 0 deletions metadata.json
@@ -0,0 +1,4 @@
{
"title": "template-datasette",
"description_html": "<p>An example of how to run <a href=\"https://datasette.readthedocs.io/\">Datasette</a> on Gitpod.</p><p>Hit the Open in Gitpod button to start an automated dev environment, in the cloud, in seconds.<p><a href=\"https://gitpod.io#https://github.com/gitpod-io/template-datasette\"><img src=\"https://gitpod.io/button/open-in-gitpod.svg\" alt=\"Open in Gitpod\" /></a></p>"
}
15 changes: 15 additions & 0 deletions requirements.txt
@@ -0,0 +1,15 @@
# Essentials:
datasette
sqlite-utils
pip

# Plugins - uncomment to install:

# - Plot latitude/longitude on a map:
# datasette-cluster-map

# - Add bar/line/scatter plots:
# datasette-vega

# More plugins here:
# https://datasette.readthedocs.io/en/stable/ecosystem.html#datasette-plugins
5 changes: 5 additions & 0 deletions start.sh
@@ -0,0 +1,5 @@
datasette .data/data.db \
-p 3000 \
-m metadata.json \
--cors \
--config default_cache_ttl:0

0 comments on commit 248b8d6

Please sign in to comment.