github
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/402#issuecomment-1030904948 | https://api.github.com/repos/simonw/sqlite-utils/issues/402 | 1030904948 | IC_kwDOCGYnMM49clx0 | 9599 | 2022-02-06T20:09:42Z | 2022-02-08T07:40:44Z | OWNER | I think this is the code that needs to become aware of this system: https://github.com/simonw/sqlite-utils/blob/fea8c9bcc509bcae75e99ae8870f520103b9aa58/sqlite_utils/db.py#L2453-L2469 There's an earlier branch that runs for upserts which needs to be modified too: https://github.com/simonw/sqlite-utils/blob/fea8c9bcc509bcae75e99ae8870f520103b9aa58/sqlite_utils/db.py#L2417-L2440 | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1125297737 | |
https://github.com/simonw/sqlite-utils/issues/402#issuecomment-1030902102 | https://api.github.com/repos/simonw/sqlite-utils/issues/402 | 1030902102 | IC_kwDOCGYnMM49clFW | 9599 | 2022-02-06T19:53:34Z | 2022-02-08T07:40:34Z | OWNER | I like the idea that the contract for `Conversion` (or rather for its subclasses) is that it can wrap a Python value and then return both the SQL fragment - e.g. `GeomFromText(?, 4326)` - and the values that should be used as the SQL parameters. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1125297737 | |
https://github.com/simonw/sqlite-utils/issues/402#issuecomment-1030901853 | https://api.github.com/repos/simonw/sqlite-utils/issues/402 | 1030901853 | IC_kwDOCGYnMM49clBd | 9599 | 2022-02-06T19:52:10Z | 2022-02-06T19:52:10Z | OWNER | So the key idea here is to introduce a new abstract base class, `Conversion`, which has the following abilities: - Can wrap one or more Python values (if called using the constructor) such that the `.insert_all()` method knows how to transform those into a format that can be included in an insert - something like `GeomFromText(?, 4326)` with input `POINT(-0.118092 51.509865)` - Can be passed to `conversions={"point": LongitudeLatitude}` in a way that then knows to apply that conversion to every value in the `"point"` key of the data being inserted. - Maybe also extend `conversions=` to allow the definition of additional keys that use as input other rows? That's the `conversions={"point": LongitudeLatitude("lng", "lat")}` example above - it may not be possible to get this working with the rest of the design though. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1125297737 | |
https://github.com/simonw/sqlite-utils/issues/402#issuecomment-1030901189 | https://api.github.com/repos/simonw/sqlite-utils/issues/402 | 1030901189 | IC_kwDOCGYnMM49ck3F | 9599 | 2022-02-06T19:48:36Z | 2022-02-06T19:48:52Z | OWNER | From [that thread](https://github.com/simonw/sqlite-utils/issues/399#issuecomment-1030739566), two extra ideas which it may be possible to support in a single implementation: ```python from sqlite_utils.conversions import LongitudeLatitude db["places"].insert( { "name": "London", "lng": -0.118092, "lat": 51.509865, }, conversions={"point": LongitudeLatitude("lng", "lat")}, ) ``` And ```python db["places"].insert( { "name": "London", "point": LongitudeLatitude(-0.118092, 51.509865) } ) ``` | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1125297737 |