{"html_url": "https://github.com/simonw/sqlite-utils/issues/136#issuecomment-710428802", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/136", "id": 710428802, "node_id": "MDEyOklzc3VlQ29tbWVudDcxMDQyODgwMg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-16T18:56:47Z", "updated_at": "2020-10-16T18:56:47Z", "author_association": "OWNER", "body": "To keep the code cleaner, I'm tempted to support this instead:\r\n\r\n --load-extension=spatialite\r\n\r\nWhere `spatialite` is a special shortcut value that triggers a search for that module in known locations.\r\n\r\nUsers could still load a module in a file called `spatialite` in the current directory using:\r\n\r\n --load-extension=./spatialite\r\n\r\nIn fact, `--load-extension=spatialite` could handle that case too by always checking for a file called `spatialite` before attempting to search for it in known locations.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 683812642, "label": "--load-extension=spatialite shortcut option"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/136#issuecomment-678508056", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/136", "id": 678508056, "node_id": "MDEyOklzc3VlQ29tbWVudDY3ODUwODA1Ng==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-21T21:13:41Z", "updated_at": "2020-08-21T21:13:41Z", "author_association": "OWNER", "body": "The `--spatialite` option should be available for other useful commands too, refs #137.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 683812642, "label": "--load-extension=spatialite shortcut option"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/136#issuecomment-678480969", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/136", "id": 678480969, "node_id": "MDEyOklzc3VlQ29tbWVudDY3ODQ4MDk2OQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-08-21T20:33:45Z", "updated_at": "2020-08-21T20:33:45Z", "author_association": "OWNER", "body": "I think this should initialize SpatiaLite against the current database if it has not been initialized already.\r\n\r\nRelevant code: https://github.com/simonw/shapefile-to-sqlite/blob/e754d0747ca2facf9a7433e2d5d15a6a37a9cf6e/shapefile_to_sqlite/utils.py#L112-L126\r\n\r\n```python\r\ndef init_spatialite(db, lib):\r\n db.conn.enable_load_extension(True)\r\n db.conn.load_extension(lib)\r\n # Initialize SpatiaLite if not yet initialized\r\n if \"spatial_ref_sys\" in db.table_names():\r\n return\r\n db.conn.execute(\"select InitSpatialMetadata(1)\")\r\n\r\n\r\ndef ensure_table_has_geometry(db, table, table_srid):\r\n if \"geometry\" not in db[table].columns_dict:\r\n db.conn.execute(\r\n \"SELECT AddGeometryColumn(?, 'geometry', ?, 'GEOMETRY', 2);\",\r\n [table, table_srid],\r\n )\r\n```\r\nNot sure if I should add a utility function or CLI command for that `ensure_table_has_geometry` bit.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 683812642, "label": "--load-extension=spatialite shortcut option"}, "performed_via_github_app": null}