Enable a limited form of table-valued functions.
Project description
datasette-ersatz-table-valued-functions
Enable a limited form of table-valued functions.
Installation
Install this plugin in the same environment as Datasette.
datasette install datasette-ersatz-table-valued-functions
Usage
Write a plugin that registers a table-valued function in the startup
hook:
from datasette import hookimpl
from datasette_ersatz_table_valued_functions import create_table_function
def tbl_squares(n):
return [(i, i*i) for i in range(n)]
@hookimpl
def startup():
create_table_function('tbl_squares', 1, tbl_squares, ['root', 'square'])
You can then query this in Datasette:
SELECT root FROM tbl_squares(10) WHERE square % 2 = 0 AND square < 50
will emit 0, 2, 4, 6.
Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd datasette-ersatz-table-valued-functions
python3 -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for datasette-ersatz-table-valued-functions-0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3de9e33d391c6aca798a4d917e7dfc2263a039cdb8143735db744e7ccd7261c |
|
MD5 | 6052bd54bdb7f0195c61c59c3766c560 |
|
BLAKE2b-256 | ef5ec22b0fa8d8396e73ed014e7284a0d0c07e4a84bbdbe7a0b07d5e4aba5133 |
Close
Hashes for datasette_ersatz_table_valued_functions-0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 631876d7ac3f7b396631b4b171ca11d0c7c07a4a845eb473a75305620b6f579a |
|
MD5 | c91527461fb937890698ce882468f0f8 |
|
BLAKE2b-256 | b3993b7bdbccaad8cf2e1a07ad8260274924735f2b14387cfa212e9375a5bd20 |