{"html_url": "https://github.com/simonw/sqlite-utils/pull/385#issuecomment-1029703216", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/385", "id": 1029703216, "node_id": "IC_kwDOCGYnMM49YAYw", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-02-04T06:45:43Z", "updated_at": "2022-02-04T06:45:43Z", "author_association": "OWNER", "body": "Shipped this as `sqlite-utils` 3.23: https://sqlite-utils.datasette.io/en/stable/changelog.html#v3-23", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1102899312, "label": "Add new spatialite helper methods"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/pull/385#issuecomment-1029682294", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/385", "id": 1029682294, "node_id": "IC_kwDOCGYnMM49X7R2", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-02-04T05:53:26Z", "updated_at": "2022-02-04T05:53:26Z", "author_association": "OWNER", "body": "This looks fantastic, thanks for all of the work you put into this!", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1102899312, "label": "Add new spatialite helper methods"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/pull/385#issuecomment-1029335225", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/385", "id": 1029335225, "node_id": "IC_kwDOCGYnMM49Wmi5", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-02-03T19:39:40Z", "updated_at": "2022-02-03T19:39:40Z", "author_association": "OWNER", "body": "> I thought about adding these as methods on `Database` and `Table`, and I'm back and forth on it for the same reasons you are. It's certainly cleaner, and it's clearer what you're operating on. I could go either way.\r\n> \r\n> I do sort of like having all the Spatialite stuff in its own module, just because it's built around an extension you might not have or want, but I don't know if that's a good reason to have a different API.\r\n> \r\n> You could have `init_spatialite` add methods to `Database` and `Table`, so they're only there if you have Spatialite set up. Is that too clever? It feels too clever.\r\n\r\nYeah that's too clever. You know what? I'm pretty confident we are both massively over-thinking this. We should put the methods on `Database` and `Table`! API simplicity and consistency matters more than vague concerns about purity.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1102899312, "label": "Add new spatialite helper methods"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/pull/385#issuecomment-1029297971", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/385", "id": 1029297971, "node_id": "IC_kwDOCGYnMM49Wdcz", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-02-03T18:52:50Z", "updated_at": "2022-02-03T18:52:50Z", "author_association": "OWNER", "body": "I'm not sure I like `name=\"geometry\"` as the default argument to `add_geometry_column` - mainly because of this example here:\r\n```python\r\nadd_geometry_column(db[\"locations\"], \"POINT\")\r\ncreate_spatial_index(db[\"locations\"], \"geometry\")\r\n```\r\nI had to go and look at the code to figure out if `\"POINT\"` was the name of the column - and I don't like how inconsistent it looks next to the following `create_spatial_index()` call where you DO need to pass the column name.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1102899312, "label": "Add new spatialite helper methods"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/pull/385#issuecomment-1029296782", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/385", "id": 1029296782, "node_id": "IC_kwDOCGYnMM49WdKO", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-02-03T18:51:21Z", "updated_at": "2022-02-03T18:51:21Z", "author_association": "OWNER", "body": "What do you think about adding these as methods on the `Database` class instead? Then you could do:\r\n\r\n```python\r\n# This is with an optional argument, which if omitted runs find_spatialite() for you:\r\ndb.init_spatialite()\r\n\r\n# Instead of:\r\ninit_spatialite(db, find_spatialite())\r\n```\r\nLikewise, the `add_geometry_column` and `create_spatial_index` methods could live on `Table`:\r\n```python\r\n# Instead of this:\r\nadd_geometry_column(db[\"locations\"], \"POINT\", \"geometry\")\r\ncreate_spatial_index(db[\"locations\"], \"geometry\")\r\n\r\n# Could have this:\r\ndb[\"locations\"].add_geometry_column(\"POINT\")\r\ndb[\"locations\"].create_spatial_index(\"geometry\")\r\n```\r\nOn the one hand, this is much more consistent with the existing `sqlite-utils` Python API.\r\n\r\nBut on the other hand... this is mixing SpatiaLite functionality directly into the core classes. Is that a good idea, seeing as SpatiaLite is both an optional extension (which can be tricky to install) AND something that has a very different release cadence and quality-of-documentation from SQLite itself?\r\n\r\nThere's a third option: the SpatiaLite could exist on subclasses of `Database` and `Table` - so the above examples would look something like this:\r\n\r\n```python\r\nfrom sqlite_utils.gis import SpatiaLiteDatabase\r\n\r\ndb = SpatiaLiteDatabase(\"geo.db\")\r\ndb.init_spatialite()\r\ndb[\"locations\"].add_geometry_column(\"POINT\")\r\ndb[\"locations\"].create_spatial_index(\"geometry\")\r\n```\r\n\r\nOn the one hand, this would keep the SpatiaLite-specific stuff out of the core Database/Table classes. But it feels a bit untidy to me, especially since it raises the spectre of someone who was already subclassing Database for some reason now needing to instead subclass `SpatiaLiteDatabase` (not too keen on that capitalization) - or even (horror) trying to dabble with multiple inheritance, which can only lead to pain.\r\n\r\nSo I don't have a strong opinion formed on this question yet!", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1102899312, "label": "Add new spatialite helper methods"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/pull/385#issuecomment-1029285985", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/385", "id": 1029285985, "node_id": "IC_kwDOCGYnMM49Wahh", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-02-03T18:37:48Z", "updated_at": "2022-02-03T18:37:48Z", "author_association": "OWNER", "body": "`from sqlite_utils.utils import find_spatialite` is part of the documented API already:\r\n\r\nhttps://sqlite-utils.datasette.io/en/3.22.1/python-api.html#finding-spatialite\r\n\r\nTo avoid needing to bump the major version number to 4 to indicate a backwards incompatible change, we should keep a `from .gis import find_spatialite` line at the top of `utils.py` such that any existing code with that documented import continues to work.", "reactions": "{\"total_count\": 1, \"+1\": 1, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1102899312, "label": "Add new spatialite helper methods"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/pull/385#issuecomment-1029273853", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/385", "id": 1029273853, "node_id": "IC_kwDOCGYnMM49WXj9", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-02-03T18:23:30Z", "updated_at": "2022-02-03T18:31:21Z", "author_association": "OWNER", "body": "OK, this change makes a bunch of sense to me - and also raises some interesting questions about future additions to `sqlite-utils` with regards to SpatiaLite. Would `sqlite-utils add-geometry-column ...` be a good CLI enhancement. for example?\r\n\r\nI see you've already talked about that in #79 - moving this conversation there!", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1102899312, "label": "Add new spatialite helper methods"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/pull/385#issuecomment-1029177015", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/385", "id": 1029177015, "node_id": "IC_kwDOCGYnMM49V_63", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-02-03T16:38:02Z", "updated_at": "2022-02-03T16:38:02Z", "author_association": "OWNER", "body": "Sorry had missed this - tests should run now.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1102899312, "label": "Add new spatialite helper methods"}, "performed_via_github_app": null}