{"id":15722109,"url":"https://github.com/cldellow/datasette-ersatz-table-valued-functions","last_synced_at":"2026-05-06T20:34:56.358Z","repository":{"id":65404830,"uuid":"591741341","full_name":"cldellow/datasette-ersatz-table-valued-functions","owner":"cldellow","description":"Enable a limited form of table-valued functions in Datasette","archived":false,"fork":false,"pushed_at":"2023-01-23T05:42:36.000Z","size":13,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-15T22:38:02.344Z","etag":null,"topics":["datasette","datasette-io","datasette-plugin","sqlite"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cldellow.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2023-01-21T18:08:27.000Z","updated_at":"2023-01-23T18:35:08.000Z","dependencies_parsed_at":"2023-02-12T20:40:14.034Z","dependency_job_id":null,"html_url":"https://github.com/cldellow/datasette-ersatz-table-valued-functions","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/cldellow/datasette-ersatz-table-valued-functions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cldellow%2Fdatasette-ersatz-table-valued-functions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cldellow%2Fdatasette-ersatz-table-valued-functions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cldellow%2Fdatasette-ersatz-table-valued-functions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cldellow%2Fdatasette-ersatz-table-valued-functions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cldellow","download_url":"https://codeload.github.com/cldellow/datasette-ersatz-table-valued-functions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cldellow%2Fdatasette-ersatz-table-valued-functions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32711377,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-06T19:35:05.142Z","status":"ssl_error","status_checked_at":"2026-05-06T19:35:03.996Z","response_time":117,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["datasette","datasette-io","datasette-plugin","sqlite"],"created_at":"2024-10-03T22:04:00.810Z","updated_at":"2026-05-06T20:34:56.307Z","avatar_url":"https://github.com/cldellow.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# datasette-ersatz-table-valued-functions\n\n[![PyPI](https://img.shields.io/pypi/v/datasette-ersatz-table-valued-functions.svg)](https://pypi.org/project/datasette-ersatz-table-valued-functions/)\n[![Changelog](https://img.shields.io/github/v/release/cldellow/datasette-ersatz-table-valued-functions?include_prereleases\u0026label=changelog)](https://github.com/cldellow/datasette-ersatz-table-valued-functions/releases)\n[![Tests](https://github.com/cldellow/datasette-ersatz-table-valued-functions/workflows/Test/badge.svg)](https://github.com/cldellow/datasette-ersatz-table-valued-functions/actions?query=workflow%3ATest)\n[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/cldellow/datasette-ersatz-table-valued-functions/blob/main/LICENSE)\n\n**ersatz** *(adj.)*: made or used as a substitute, typically an inferior one, for something else.\n\nEnable a limited form of table-valued functions.\n\nSee also [ersatz-table-valued-functions](https://github.com/cldellow/ersatz-table-valued-functions/).\n\n## Installation\n\nInstall this plugin in the same environment as Datasette.\n\n    datasette install datasette-ersatz-table-valued-functions\n\n## Usage\n\nWrite a plugin that registers a table-valued function in the `startup` hook:\n\n```python\nfrom datasette import hookimpl\nfrom datasette_ersatz_table_valued_functions import create_table_function\n\ndef tbl_squares(n):\n    return [(i, i*i) for i in range(n)]\n\n@hookimpl\ndef startup():\n    create_table_function('tbl_squares', 1, tbl_squares, ['root', 'square'])\n```\n\nYou can then query this in Datasette:\n\n```sql\nSELECT root FROM tbl_squares(10) WHERE square % 2 = 0 AND square \u003c 50\n```\n\nwill emit 0, 2, 4, 6.\n\nThe parameters to the function can come from a subselect, which could target\nany table and be arbitrarily complex:\n\n```sql\nSELECT root FROM tbl_squares((SELECT 10))\n```\n\nYou can do whatever with the output of this function -- join it, aggregate it, etc.\n\nWhat you can't do is use a join as the source of _input_ to the function:\n\n```sql\nWITH xs AS (SELECT 10 AS x) SELECT root FROM tbl_squares(x), xs\n```\n\nQueries that aren't supported are passed as-is to SQLite, which will itself\nthen reject them since no such table function is registered.\n\n## Development\n\nTo set up this plugin locally, first checkout the code. Then create a new virtual environment:\n\n    cd datasette-ersatz-table-valued-functions\n    python3 -m venv venv\n    source venv/bin/activate\n\nNow install the dependencies and test dependencies:\n\n    pip install -e '.[test]'\n\nTo run the tests:\n\n    pytest\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcldellow%2Fdatasette-ersatz-table-valued-functions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcldellow%2Fdatasette-ersatz-table-valued-functions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcldellow%2Fdatasette-ersatz-table-valued-functions/lists"}