home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 1671500965

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions issue performed_via_github_app
https://github.com/simonw/datasette/issues/2134#issuecomment-1671500965 https://api.github.com/repos/simonw/datasette/issues/2134 1671500965 IC_kwDOBm6k_c5joRSl 9599 2023-08-09T14:31:43Z 2023-08-09T14:31:43Z OWNER

Here's a simple plugin that can do this: ```python from datasette import hookimpl

@hookimpl def startup(datasette): db = datasette.add_memory_database("counters")

async def inner():
    await db.execute_write("create table if not exists counters (name text primary key, value integer)")
    await db.execute_write("insert or ignore into counters (name, value) values ('counter', 0)")

return inner

@hookimpl def canned_queries(database): if database == "counters": return { "increment": { "sql": "update counters set value = value + 1 where name = 'counter'", "write": True, }, "decrement": { "sql": "update counters set value = value - 1 where name = 'counter'", "write": True, }, } ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
1843391585  
Powered by Datasette · Queries took 0.849ms · About: github-to-sqlite