repos: 275624346
This data as json
id | node_id | name | full_name | private | owner | html_url | description | fork | created_at | updated_at | pushed_at | homepage | size | stargazers_count | watchers_count | language | has_issues | has_projects | has_downloads | has_wiki | has_pages | forks_count | archived | disabled | open_issues_count | license | topics | forks | open_issues | watchers | default_branch | permissions | temp_clone_token | organization | network_count | subscribers_count | readme | readme_html | allow_forking | visibility | is_template | template_repository | web_commit_signoff_required | has_discussions |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
275624346 | MDEwOlJlcG9zaXRvcnkyNzU2MjQzNDY= | datasette-init | simonw/datasette-init | 0 | 9599 | https://github.com/simonw/datasette-init | Ensure specific tables and views exist on startup | 0 | 2020-06-28T16:26:29Z | 2021-06-14T19:43:55Z | 2020-07-01T22:47:09Z | 9 | 1 | 1 | Python | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 | 0 | [] | 0 | 0 | 1 | main | {"admin": false, "push": false, "pull": false} | 0 | 1 | # datasette-init [](https://pypi.org/project/datasette-init/) [](https://github.com/simonw/datasette-init/releases) [](https://github.com/simonw/datasette-init/blob/master/LICENSE) Ensure specific tables and views exist on startup ## Installation Install this plugin in the same environment as Datasette. $ pip install datasette-init ## Usage This plugin is configured using `metadata.json` (or `metadata.yaml`). ### Creating tables Add a block like this that specifies the tables you would like to ensure exist: ```json { "plugins": { "datasette-init": { "my_database": { "tables": { "dogs": { "columns": { "id": "integer", "name": "text", "age": "integer", "weight": "float" }, "pk": "id" } } } } } } ``` Any tables that do not yet exist will be created when Datasette first starts. Valid column types are `"integer"`, `"text"`, `"float"` and `"blob"`. The `"pk"` is optional, and is used to define the primary key. To define a compound primary key (across more than one column) use a list of column names here: ```json "pk": ["id1", "id2"] ``` ### Creating views The plugin can also be used to create views: ```json { "plugins": { "datasette-init": { "my_database": { "views": { "my_view": "select 1 + 1" } } } } } ``` Each view in the ``"views"`` block will be created when the Database first starts. If a view with the same name already exists it will be replaced with the new definition. ## Development To set up this plugin locally, first checkout the code. Then create a new virtual environment: cd datasette-init python3 -mvenv venv source venv/bin/activate Or if you are using `pipenv`: pipenv shell Now install the dependencies and tests: pip install -e '.[test]' To run the tests: pytest | <div id="readme" class="md" data-path="README.md"><article class="markdown-body entry-content container-lg" itemprop="text"><h1><a id="user-content-datasette-init" class="anchor" aria-hidden="true" href="#user-content-datasette-init"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>datasette-init</h1> <p><a href="https://pypi.org/project/datasette-init/" rel="nofollow"><img src="https://camo.githubusercontent.com/83fefe5c408de5ede9ce3a712c8133a53de0da3cea828b513827c7d14c4c3cb2/68747470733a2f2f696d672e736869656c64732e696f2f707970692f762f6461746173657474652d696e69742e737667" alt="PyPI" data-canonical-src="https://img.shields.io/pypi/v/datasette-init.svg" style="max-width:100%;"></a> <a href="https://github.com/simonw/datasette-init/releases"><img src="https://camo.githubusercontent.com/c60721d7193f69d423216b711462556b27b48be0c5b33e74b1831a2daea05bdc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f73696d6f6e772f6461746173657474652d696e69743f6c6162656c3d6368616e67656c6f67" alt="Changelog" data-canonical-src="https://img.shields.io/github/v/release/simonw/datasette-init?label=changelog" style="max-width:100%;"></a> <a href="https://github.com/simonw/datasette-init/blob/master/LICENSE"><img src="https://camo.githubusercontent.com/1698104e976c681143eb0841f9675c6f802bb7aa832afc0c7a4e719b1f3cf955/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d417061636865253230322e302d626c75652e737667" alt="License" data-canonical-src="https://img.shields.io/badge/license-Apache%202.0-blue.svg" style="max-width:100%;"></a></p> <p>Ensure specific tables and views exist on startup</p> <h2><a id="user-content-installation" class="anchor" aria-hidden="true" href="#user-content-installation"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Installation</h2> <p>Install this plugin in the same environment as Datasette.</p> <div class="snippet-clipboard-content position-relative" data-snippet-clipboard-copy-content="$ pip install datasette-init "><pre><code>$ pip install datasette-init </code></pre></div> <h2><a id="user-content-usage" class="anchor" aria-hidden="true" href="#user-content-usage"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Usage</h2> <p>This plugin is configured using <code>metadata.json</code> (or <code>metadata.yaml</code>).</p> <h3><a id="user-content-creating-tables" class="anchor" aria-hidden="true" href="#user-content-creating-tables"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Creating tables</h3> <p>Add a block like this that specifies the tables you would like to ensure exist:</p> <div class="highlight highlight-source-json position-relative" data-snippet-clipboard-copy-content="{ "plugins": { "datasette-init": { "my_database": { "tables": { "dogs": { "columns": { "id": "integer", "name": "text", "age": "integer", "weight": "float" }, "pk": "id" } } } } } } "><pre>{ <span class="pl-s"><span class="pl-pds">"</span>plugins<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>datasette-init<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>my_database<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>tables<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>dogs<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>columns<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>id<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>integer<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>name<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>text<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>age<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>integer<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>weight<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>float<span class="pl-pds">"</span></span> }, <span class="pl-s"><span class="pl-pds">"</span>pk<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>id<span class="pl-pds">"</span></span> } } } } } }</pre></div> <p>Any tables that do not yet exist will be created when Datasette first starts.</p> <p>Valid column types are <code>"integer"</code>, <code>"text"</code>, <code>"float"</code> and <code>"blob"</code>.</p> <p>The <code>"pk"</code> is optional, and is used to define the primary key. To define a compound primary key (across more than one column) use a list of column names here:</p> <div class="highlight highlight-source-json position-relative" data-snippet-clipboard-copy-content=" "pk": ["id1", "id2"] "><pre> <span class="pl-s"><span class="pl-pds">"</span>pk<span class="pl-pds">"</span></span>: [<span class="pl-s"><span class="pl-pds">"</span>id1<span class="pl-pds">"</span></span>, <span class="pl-s"><span class="pl-pds">"</span>id2<span class="pl-pds">"</span></span>]</pre></div> <h3><a id="user-content-creating-views" class="anchor" aria-hidden="true" href="#user-content-creating-views"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Creating views</h3> <p>The plugin can also be used to create views:</p> <div class="highlight highlight-source-json position-relative" data-snippet-clipboard-copy-content="{ "plugins": { "datasette-init": { "my_database": { "views": { "my_view": "select 1 + 1" } } } } } "><pre>{ <span class="pl-s"><span class="pl-pds">"</span>plugins<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>datasette-init<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>my_database<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>views<span class="pl-pds">"</span></span>: { <span class="pl-s"><span class="pl-pds">"</span>my_view<span class="pl-pds">"</span></span>: <span class="pl-s"><span class="pl-pds">"</span>select 1 + 1<span class="pl-pds">"</span></span> } } } } }</pre></div> <p>Each view in the <code>"views"</code> block will be created when the Database first starts. If a view with the same name already exists it will be replaced with the new definition.</p> <h2><a id="user-content-development" class="anchor" aria-hidden="true" href="#user-content-development"><svg class="octicon octicon-link" viewBox="0 0 16 16" version="1.1" width="16" height="16" aria-hidden="true"><path fill-rule="evenodd" d="M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z"></path></svg></a>Development</h2> <p>To set up this plugin locally, first checkout the code. Then create a new virtual environment:</p> <div class="snippet-clipboard-content position-relative" data-snippet-clipboard-copy-content="cd datasette-init python3 -mvenv venv source venv/bin/activate "><pre><code>cd datasette-init python3 -mvenv venv source venv/bin/activate </code></pre></div> <p>Or if you are using <code>pipenv</code>:</p> <div class="snippet-clipboard-content position-relative" data-snippet-clipboard-copy-content="pipenv shell "><pre><code>pipenv shell </code></pre></div> <p>Now install the dependencies and tests:</p> <div class="snippet-clipboard-content position-relative" data-snippet-clipboard-copy-content="pip install -e '.[test]' "><pre><code>pip install -e '.[test]' </code></pre></div> <p>To run the tests:</p> <div class="snippet-clipboard-content position-relative" data-snippet-clipboard-copy-content="pytest "><pre><code>pytest </code></pre></div> </article></div> |
Links from other tables
- 4 rows from repo in releases