home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 1030736589

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/399#issuecomment-1030736589 https://api.github.com/repos/simonw/sqlite-utils/issues/399 1030736589 IC_kwDOCGYnMM49b8rN 9599 2022-02-06T02:14:52Z 2022-02-06T02:14:52Z OWNER

Another idea: introduce a helper function transform pattern, something a bit like this:

```python

transformer = make_transformer({ "point": lambda pair: "POINT({} {})".format(pair[1], pair[0]) })

db["places"].insert_all( transformer([{"name": "London", "point": (51.509865, -0.118092)}]) conversions={"point": "GeomFromText(?, 4326)"}, ) `` Themake_transformer(...)` function builds an object that can work as a wrapping iterator, applying those transform functions to everything in the sequence that it wraps.

So the above code would handle converting (lat, lon) to POINT(lon lat) - then the conversions= applies GeomFromText.

Naming is a challenge here: .transform() and .convert() and conversions= all have existing meanings within the sqlite-utils Python library.

It's also a bit of a messy way of solving this. It's not exactly a smooth API for inserting a bunch of lat/lon coordinate pairs!

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