Saravanan666/pypi-org huggingface dataset:
Package: datasette-build
datasette-buildBuild a directory full of files into a SQLite database⚠️Early alpha preview. Everything about this tool is likely to change.InstallationInstall this tool usingpiporpipx:pipxinstalldatasette-buildThis will provide thedatasette-buildCLI application.You can also install it as a Datasette plugin. Firstinstall Datasette, then run:datasetteinstalldatasette-buildThis will provide adatasette build ...command that works the same as thedatasette-buildCLI application.Or you can install it as a plugin forsqlite-utils. With that installed, run this:sqlite-utilsinstalldatasette-buildNow you can access the tool assqlite-utils build ...UsageThedatasette-build(ordatasette buildorsqlite-utils build) command takes two arguments: a path to a SQLite database file and a path to a directory containing files to be loaded into that database:datasette-buildmydatabase.dbmyfiles/Themyfiles/folder can contain a mixture of CSV, TSV and JSON files. Each file will be loaded into a table in themydatabase.dbSQLite database.The database file will be created if it does not already exist.Consider amyfiles/cities.csvfile like this:id,name,latitude,longitude,country
nyc,New York City,40.7128,-74.006,US
lon,London,51.5074,-0.1278,GB
tok,Tokyo,35.6895,139.6917,JP
par,Paris,48.8566,2.3522,FR
ber,Berlin,52.52,13.405,DE
syd,Sydney,-33.8688,151.2093,AU
cai,Cairo,30.0444,31.2357,EG
rio,Rio de Janeiro,-22.9068,-43.1729,BR
mos,Moscow,55.7558,37.6173,RU
mum,Mumbai,19.076,72.8777,INSince this has aidcolumn the primary key for the table will be set toid. Without anidcolumn the primary key will not be defined.Amyfiles/counties.tsvfile could look like this:id	name	population
US	United States	331002651
GB	United Kingdom	67886011
JP	Japan	126476461
FR	France	65273511
DE	Germany	83783942
AU	Australia	25499884
EG	Egypt	102334404
BR	Brazil	212559417
RU	Russia	145934462
IN	India	1380004385And amyfiles/museums.jsonfile like this:[{"id":1,"name":"Metropolitan Museum of Art","city_id":"nyc"},{"id":2,"name":"British Museum","city_id":"lon"}]Runningdatasette-build mydatabase.db myfiles/will create a SQLite database file containing three tables:cities,countiesandmuseums. The schema will look like this:CREATETABLE[museums]([id]INTEGERPRIMARYKEY,[name]TEXT,[city_id]TEXT);CREATETABLE"cities"([id]TEXTPRIMARYKEY,[name]TEXT,[latitude]FLOAT,[longitude]FLOAT,[country]TEXT);CREATETABLE"countries"([id]TEXTPRIMARYKEY,[name]TEXT,[population]INTEGER);DevelopmentTo set up this plugin locally, first checkout the code. Then create a new virtual environment:cddatasette-build
python3-mvenvvenvsourcevenv/bin/activateNow install the dependencies and test dependencies:pipinstall-e'.[test]'To run the tests:pytest
Package: datasette-chartjs
datasette-chartjsChart.js integration for datasetteInstallationInstall this plugin in the same environment as Datasette.$ datasette install datasette-chartjsUsageUsage instructions go here.DevelopmentTo set up this plugin locally, first checkout the code. Then create a new virtual environment:$ cd datasette-chartjs
$ python3 -mvenv venv
(venv)$ source venv/bin/activateOr if you are usingpipenv:$ pipenv shellNow install the dependencies and tests:(venv)$ pip install -e '.[dev,test]'To run the tests:(venv)$ pytestThe project also usespre-commitfor linting and formatting of source code:(venv)$ pre-commit install -t pre-commit -t pre-push --install-hooks
Package: datasette-chatgpt-plugin
datasette-chatgpt-pluginA Datasette plugin that turns a Datasette instance into a ChatGPT plugin - so you can use ChatGPT to ask questions of your data.For more on this project, seeBuilding a ChatGPT plugin to ask questions of data hosted in Datasette.InstallationInstall this plugin in the same environment as Datasette, on a deployed instance.datasette install datasette-chatgpt-pluginOr if you are usingdatasette publishto deploy Datasette:datasette publish cloudrun/vercel/fly/heroku data.db \
  --install datasette-chatgpt-pluginUsageOnce installed, your Datasette instance will work with the newChatGPT pluginssystem - provided you have access to that preview.ClickPlugins -> Plugin store -> Install an unverified pluginand enter the URL of your Datasette instance.ChatGPT will discover the plugin by hitting the/.well-known/ai-plugin.jsonendpoint.You can then ask it questions! Some starting examples:Show a list of tables (this is always good to start with as it ensures ChatGPT knows which tables are available)Show the first 10 rows of themytabletableThis plugin currently exposes a single database - the first database attached to your instance.DevelopmentTo set up this plugin locally, first checkout the code. Then create a new virtual environment:cd datasette-chatgpt-plugin
python3 -m venv venv
source venv/bin/activateNow install the dependencies and test dependencies:pip install -e '.[test]'To run the tests:pytest
Package: datasette-chronicle
datasette-chronicleUsesqlite-chroniclewith tables in DatasetteInstallationInstall this plugin in the same environment as Datasette.datasetteinstalldatasette-chronicleUsageOnce installed, users with theenable-chronicleanddisable-chroniclepermissions (granted to therootuser by default) will have access to new table action menu options for enabling and disabling chronicle tracking for a table.Tables that have had chronicle tracking enabled will now support a new?_since=Xquery string parameter on the table page, which will filter for just rows that have been inserted or updated since the specified chronicle version.See thesqlite-chronicle documentationfor more details on what this is and how it works.DevelopmentTo set up this plugin locally, first checkout the code. Then create a new virtual environment:cddatasette-chronicle
python3-mvenvvenvsourcevenv/bin/activateNow install the dependencies and test dependencies:pipinstall-e'.[test]'To run the tests:pytest
Package: datasette-cldf
datasette-cldfDatasetteplugin to explore CLDF datasetsCLDFdatasets can be easily loaded into SQLite databases
(running thecldf createdbcommand provided withpycldf). Thus, they can be readily explored via the web interface provided by
datasette.This plugin exploits the "semantics" of CLDF to customize datasette, e.g. to displayglottocodecolumns as hyperlinks tohttps://glottolog.orgor to display rows of anExampleTablecomponent as interlinear glossed text, i.e. with
aligned morphemes and glosses.Usagedatasette-cldfcustomizes datasette by providingcustomdatasette metadatacustom templatesand custom configuration.Thus, instead of calling thedatasettecli directly, ỳou call thedatasette.servesubcommand, which this package registers withcldfbench:cldfbenchdatasette.servePATH/TO/cldf-metadata.jsonFeaturesWe'll show the customizations provided by this plugin with a series of screenshots
of datasette serving theWorld Atlas of Language Structures.Languages are displayed on a mapLanguage details also show a mapand link to feature values of the languageFeature pages list possible values and their distributionSources are formatted according to theUnified Style Sheetand as BibTeX recordsExamples are formatted as interlinear glossed text according to theLeipzig Glossing Rules
Package: datasette-clone
datasette-cloneCreate a local copy of database files from a Datasette instance.Seedatasette-cloneon my blog for background on this project.How to install$ pip install datasette-cloneUsageThis only works against Datasette instances running immutable databases (with the-ioption). Databases published using thedatasette publishcommand should be compatible with this tool.To download copies of all.dbfiles from an instance, run:datasette-clone https://latest.datasette.ioYou can provide an optional second argument to specify a directory:datasette-clone https://latest.datasette.io /tmp/here-pleaseThe command stores its own copy of adatabases.jsonmanifest and uses it to only download databases that have changed the next time you run the command.It also stores a copy of the instance'smetadata.jsonto ensure you have a copy of any source and licensing information for the downloaded databases.If your instance is protected by an API token, you can use--tokento provide it:datasette-clone https://latest.datasette.io --token=xyzFor verbose output showing what the tool is doing, use-v.
Package: datasette-codespaces
datasette-codespacesConveniences for runningDatasetteonGitHub CodespacesInstallationInstall this plugin in the same environment as Datasette.datasette install datasette-codespacesTutorialUsing Datasette in GitHub Codespacesprovides a detailed tutorial introduction to this plugin.UsageInstall this when you are using Datasette inside of GitHub Codespaces. It makes the following changes:All requests will be treated as therootactor provided Datasette is running inside Codespaces (detected through the presence of theCODESPACE_NAMEenvironment variable). This should still be secure as GitHub restricts access to servers running in the Codespaces environment based on GitHub authentication.Thedatasette-x-forwarded-hostplugin will be installed, ensuring links to other pages within Datasette such as facet navigation work correctly.DevelopmentTo set up this plugin locally, first checkout the code. Then create a new virtual environment:cd datasette-codespaces
python3 -m venv venv
source venv/bin/activateNow install the dependencies and test dependencies:pip install -e '.[test]'To run the tests:pytest
Package: datasette-comments
datasette-commentsA Datasette plugin for commenting on tables, rows, and values. Work in progress, not ready yet!InstallationInstall this plugin in the same environment as Datasette.datasetteinstalldatasette-commentsUsageOnce installed, users with thedatasette-comments-accesswill be able to view and add comments on rows within their Datasette instance.Plugin hooksThis plugin provies the following plugin hook which can be used to customize its behavior:datasette_comments_users(datasette)This hook should return a list of dictionaries, each representing a user that should be made available to the plugin. Each dictionary should have the following keys:id: A unique ID of the user, same as the actor ID.username: A unique string that is used in searches and @ mentions.name: A string of the user's natural name.profile_photo_url: Optional URL to the user's profile pic.email: Optional email used for gravatar profile photo, if enabled.The plugin hook can return a list, or it can return an awaitable function that returns a list.DevelopmentTo set up this plugin locally, first checkout the code. Then create a new virtual environment:cddatasette-comments
python3-mvenvvenvsourcevenv/bin/activateNow install the dependencies and test dependencies:pipinstall-e'.[test]'And for the JavaScript dependencies (needed to run a JavaScript build):npminstallTo run the tests:pytestTo rebuild the minified JavaScript after making a change to a.tsor.tsxfile:justjs
Package: datasette-configure-asgi
datasette-configure-asgiDatasette plugin for configuring arbitrary ASGI middlewareInstallationpip install datasette-configure-asgiUsageThis plugin only takes effect if yourmetadata.jsonfile contains relevant top-level plugin configuration in a"datasette-configure-asgi"configuration key.For example, to wrap your Datasette instance in theasgi-log-to-sqlitemiddleware configured to write logs to/tmp/log.dbyou would use the following:{"plugins":{"datasette-configure-asgi":[{"class":"asgi_log_to_sqlite.AsgiLogToSqlite","args":{"file":"/tmp/log.db"}}]}}The"datasette-configure-asgi"key should be a list of JSON objects. Each object should have a"class"key indicating the class to be used, and an optional"args"key providing any necessary arguments to be passed to that class constructor.Plugin structureThis plugin can be used to wrap your Datasette instance in any ASGI middleware that conforms to the following structure:classSomeAsgiMiddleware:def__init__(self,app,arg1,arg2):self.app=appself.arg1=arg1self.arg2=arg2asyncdef__call__(self,scope,receive,send):start=time.time()awaitself.app(scope,receive,send)end=time.time()print("Time taken:{}".format(end-start))So the middleware is a class with a constructor which takes the wrapped application as a first argument,app, followed by further named arguments to configure the middleware. It provides anasync def __call__(self, scope, receive, send)method to implement the middleware's behavior.
Package: datasette-configure-fts
datasette-configure-ftsDatasette plugin for enabling full-text search against selected table columnsInstallationInstall this plugin in the same environment as Datasette.$ datasette install datasette-configure-ftsUsageHaving installed the plugin, visit/-/configure-ftson your Datasette instance to configure FTS for tables on attached writable databases.Any time you have permission to configure FTS for a table a menu item will appear in the table actions menu on the table page.By default onlythe root actorcan access the page - so you'll need to run Datasette with the--rootoption and click on the link shown in the terminal to sign in and access the page.Theconfigure-ftspermission governs access. You can use permission plugins such asdatasette-permissions-sqlto grant additional access to the write interface.
Package: datasette-connectors
datasette-connectorsDatasetteis a Python module which provides a web interface and a JSON API for SQLite files. But, in conjuntion with Datasette-Connectors, it can accept external connectors for any kind of database files, so you can develop your own connector for your favourite data container if you want (readdevelopers doc).InstallationRunpip install datasette-connectorsto install both Datasette and Datasette-Connectors. Easy as pie!UsageYou can use Datasette from the console in the traditional way:datasette serve path/to/data.h5This will start a web server on port 8001; then you can access to your data visitinghttp://localhost:8001/Or you can use Datasette in your own Python programs:from datasette_connectors import monkey; monkey.patch_datasette()
from datasette_connectors import connectors; connectors.load()For that, you need to patch the original Datasette and load the external connectors.Read theDatasette documentationfor more advanced options.
Package: datasette-cookies-for-magic-parameters
datasette-cookies-for-magic-parametersUI for setting cookies to populate magic parametersInstallationInstall this plugin in the same environment as Datasette.datasette install datasette-cookies-for-magic-parametersUsageThis plugin only affects canned queries. If you have a canned query configured like this:databases:mydatabase:queries:api_query:sql:select 'Your API key is' || :_cookie_openai_api_token;Then the/mydatabase/api_querypage will include a new interface for setting theopenapi_api_tokencookie, or unsetting it if it has already been set.Why use this?This plugin was initially developed to use withdatasette-openai- a plugin that provides custom SQL functions that take an API token as one of their parameters.Passing these API tokens in a GET query string is unsafe, as they may leak through referrers or other log files.Instead, this plugin enables them to be set and passed using a cookie, which is much less likely to be logged.This pattern takes advantage of the:_cookie_xfeature of Datasette'smagic parametersmechanism.DevelopmentTo set up this plugin locally, first checkout the code. Then create a new virtual environment:cd datasette-cookies-for-magic-parameters
python3 -m venv venv
source venv/bin/activateNow install the dependencies and test dependencies:pip install -e '.[test]'To run the tests:pytest
Package: datasette-copyable
datasette-copyableDatasette plugin for outputting tables in formats suitable for copy and pasteInstallationInstall this plugin in the same environment as Datasette.$ pip install datasette-copyableDemoYou can try this plugin onfivethirtyeight.datasettes.com- browse for tables or queries there and look for the "copyable" link. Here's an example for a table ofairline safety data.UsageThis plugin adds a.copyableoutput extension to every table, view and query.Navigating to this page will show an interface allowing you to select a format for copying and pasting the demo. The default is TSV, which is suitable for copying into Google Sheets or Excel.You can add?_raw=1to get back just the raw data.DevelopmentTo set up this plugin locally, first checkout the code. Then create a new virtual environment:cd datasette-copyable
python3 -mvenv venv
source venv/bin/activateOr if you are usingpipenv:pipenv shellNow install the dependencies and tests:pip install -e '.[test]'To run the tests:pytest
Package: datasette-copy-to-memory
datasette-copy-to-memoryCopy database files into an in-memory database on startupThis plugin ishighly experimental. It currently exists to support Datasette performance research, and is not designed for actual production usage.InstallationInstall this plugin in the same environment as Datasette.datasette install datasette-copy-to-memoryUsageOn startup, Datasette will create an in-memory named database for each attached database. This database will have the same name but with_memoryat the end.So running this:datasette fixtures.dbWill serve two databases: the original at/fixturesand the in-memory copy at/fixtures_memory.DemoA demo is running onlatest-with-plugins.datasette.io- the/fixtures_memorytable there is provided by this plugin.ConfigurationBy default every attached database file will be loaded into a_memorycopy.You can use plugin configuration to specify just a subset of the database. For example, to creategithub_memorybut notfixtures_memoryyou would use the followingmetadata.ymlfile:plugins:datasette-copy-to-memory:databases:-githubThen start Datasette like this:datasette github.db fixtures.db -m metadata.ymlIf you don't want to have afixturesandfixtures_memorydatabase, you can usereplace: trueto have the plugin replace the file-backed database with the new in-memory one, reusing the same database name:plugins:datasette-copy-to-memory:replace:trueThen:datasette github.db fixtures.db -m metadata.ymlThis will result in both/githuband/fixturesbut no/github_memoryor/fixtures_memory.DevelopmentTo set up this plugin locally, first checkout the code. Then create a new virtual environment:cd datasette-copy-to-memory
python3 -m venv venv
source venv/bin/activateNow install the dependencies and test dependencies:pip install -e '.[test]'To run the tests:pytest
Package: datasette-cors
datasette-corsDatasette plugin for configuring CORS headers, based onhttps://github.com/simonw/asgi-corsYou can use this plugin to allow JavaScript running on a whitelisted set of domains to makefetch()calls to the JSON API provided by your Datasette instance.Installationpip install datasette-corsConfigurationYou need to add some configuration to your Datasettemetadata.jsonfile for this plugin to take effect.To whitelist specific domains, use this:{"plugins":{"datasette-cors":{"hosts":["https://www.example.com"]}}}You can also whitelist patterns like this:{"plugins":{"datasette-cors":{"host_wildcards":["https://*.example.com"]}}}Testing itTo test this plugin out, run it locally by saving one of the above examples asmetadata.jsonand running this:$ datasette --memory -m metadata.jsonNow visithttps://www.example.com/in your browser, open the browser developer console and paste in the following:fetch("http://127.0.0.1:8001/:memory:.json?sql=select+sqlite_version%28%29").then(r=>r.json()).then(console.log)If the plugin is running correctly, you will see the JSON response output to the console.
Package: datasette-css-properties
datasette-css-propertiesExtremely experimental Datasette output plugin using CSS properties, inspired byCustom Properties as Stateby Chris Coyier.InstallationInstall this plugin in the same environment as Datasette.$ datasette install datasette-css-propertiesUsageOnce installed, this plugin adds a.cssoutput format to every query result. This will return the first row in the query as a valid CSS file, defining each column as a custom property:Example:https://latest-with-plugins.datasette.io/fixtures/roadside_attractions.cssproduces::root{--pk:'1';--name:'The Mystery Spot';--address:'465 Mystery Spot Road, Santa Cruz, CA 95065';--latitude:'37.0167';--longitude:'-122.0024';}If you link this stylesheet to your page you can then do things like this;<linkrel="stylesheet"href="https://latest-with-plugins.datasette.io/fixtures/roadside_attractions.css"><style>.attraction-name:after{content:var(--name);}</style><pclass="attraction-name">Attraction name:</p>Values will be quoted as CSS strings by default. If you want to return a "raw" value without the quotes - for example to set a CSS property that is numeric or a color, you can specify that column name using the?_raw=column-nameparameter. This can be passed multiple times.Considerthis example query:select'#'||substr(sha,0,6)as[custom-bg]fromcommitsorderbyauthor_datedesclimit1;This returns the first 6 characters of the most recently authored commit with a#prefix. The.cssoutput rendered versionlooks like this::root{--custom-bg:'#97fb1';}Adding?_raw=custom-bgto the URL producesthis instead::root{--custom-bg:#97fb1;}This can then be used as a color value like so:h1{background-color:var(--custom-bg);}DevelopmentTo set up this plugin locally, first checkout the code. Then create a new virtual environment:cd datasette-css-properties
python3 -mvenv venv
source venv/bin/activateOr if you are usingpipenv:pipenv shellNow install the dependencies and tests:pip install -e '.[test]'To run the tests:pytest
Package: datasette-current-actor
datasette-current-actorAdds acurrent_actor()function to SQLite that show's the current actor's ID.InstallationInstall this plugin in the same environment as Datasette.datasette install datasette-current-actorUsagecurrent_actor()returns the current actor's ID, orNULLif no actor.current_actor('attrs', 'name')navigates the actor object, returning
the value of thenamekey stored in theattrskey, orNULLif any
of the intermediate values are absent.current_actor_ip()returns the current actor's IP addresscurrent_actor_user_agent()returns the current actor's HTTP user agentDefault values, views and triggersSQLite isflexible. It turns out you can refer to functions that don't exist
when issuing DDL statements. As long as they exist when they're needed, it all
works out.AuditingTrack who added a row:CREATETABLEnotes(created_bytextnotnulldefault(current_actor()),created_by_iptextnotnulldefault(current_actor_ip()),notetextnotnull);Or create an UPDATE trigger on a table that sets thelast_edited_bycolumn tocurrent_actor().Row-level securityRestrict the rows that users see:CREATEVIEWrlsASSELECT*FROMsensitive_dataWHEREowner=current_actor()You can see a live example athttps://dux.fly.dev/cooking/my_questions, which should show you 0 rows.That instance permits "logging in" by passing a_whoamiquery parameter. If you visithttps://dux.fly.dev/cooking/my_questions?_whoami=15, you'll see all of user 15's questions.DevelopmentTo set up this plugin locally, first checkout the code. Then create a new virtual environment:cd datasette-current-actor
python3 -m venv venv
source venv/bin/activateNow install the dependencies and test dependencies:pip install -e '.[test]'To run the tests:pytest
Package: datasette-debug-actors-from-ids
datasette-debug-actors-from-idsA Datasette plugin for debugging thenew actors_from_ids plugin hook.Installationdatasetteinstalldatasette-debug-actors-from-idsUsageAdds a URL at/-/debug-actors-from-ids. Call it with?ids=1,3,4to exercise the plugin hook.DevelopmentTo set up this plugin locally, first checkout the code. Then create a new virtual environment:cddatasette-debug-actors-from-ids
python3-mvenvvenvsourcevenv/bin/activateNow install the dependencies and test dependencies:pip install -e '.[test]'To run the tests:
```bash
pytest
Package: datasette-debug-asgi
datasette-debug-asgiDatasette plugin for dumping out the ASGI scope.Adds a new URL at/-/asgi-scopewhich shows the current ASGI scope. Demo here:https://datasette.io/-/asgi-scopeInstallationpip install datasette-debug-asgiUsageVisit/-/asgi-scopeto see debug output showing the ASGI scope.You can add query string parameters such as/-/asgi-scope?q=hello.You can also add extra path components such as/-/asgi-scope/more/path/here.