home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 865511810

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/sqlite-utils/issues/290#issuecomment-865511810 https://api.github.com/repos/simonw/sqlite-utils/issues/290 865511810 MDEyOklzc3VlQ29tbWVudDg2NTUxMTgxMA== 9599 2021-06-22T04:07:34Z 2021-06-22T18:26:21Z OWNER

That documentation section is pretty weak at the moment - here's the whole thing:

Executing queries

The db.execute() and db.executescript() methods provide wrappers around .execute() and .executescript() on the underlying SQLite connection. These wrappers log to the tracer function if one has been registered. python db = Database(memory=True) db["dogs"].insert({"name": "Cleo"}) db.execute("update dogs set name = 'Cleopaws'") You can pass parameters as an optional second argument, using either a list or a dictionary. These will be correctly quoted and escaped. ```python

Using ? and a list:

db.execute("update dogs set name = ?", ["Cleopaws"])

Or using :name and a dictionary:

db.execute("update dogs set name = :name", {"name": "Cleopaws"}) ```

  • Talks about .execute() - I want to talk about .query() instead
  • Doesn't clarify that .execute() returns a Cursor - and assumes you know what to do with one
  • Doesn't show an example of a select query at all
  • The "tracer function" bit is confusing (should at least link to docs further down)
  • For UPDATE should show how to access the number of rows modified (probably using .execute() there)

It does at least cover the two types of parameters, though that could be bulked out.

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