Skip to content

Conversation

eyeseast
Copy link
Contributor

Closes #398

This adds SpatiaLite helpers to the CLI.

# init spatialite when creating a database
sqlite-utils create database.db --enable-wal --init-spatialite

# add geometry columns
# needs a database, table, geometry column name, type, with optional SRID and not-null
# this will throw an error if the table doesn't already exist
sqlite-utils add-geometry-column database.db table-name geometry --srid 4326 --not-null

# spatial index an existing table/column
# this will throw an error it the table and column don't exist
sqlite-utils create-spatial-index database.db table-name geometry

Docs and tests are included.

@codecov
Copy link

codecov bot commented Feb 15, 2022

Codecov Report

Merging #407 (a974da5) into main (e7f0401) will increase coverage by 0.71%.
The diff coverage is 85.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #407      +/-   ##
==========================================
+ Coverage   95.91%   96.62%   +0.71%     
==========================================
  Files           6        6              
  Lines        2421     2460      +39     
==========================================
+ Hits         2322     2377      +55     
+ Misses         99       83      -16     
Impacted Files Coverage Δ
sqlite_utils/cli.py 95.76% <85.00%> (+0.06%) ⬆️
sqlite_utils/utils.py 94.59% <0.00%> (ø)
sqlite_utils/db.py 97.72% <0.00%> (+1.43%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e7f0401...a974da5. Read the comment docs.

@eyeseast
Copy link
Contributor Author

@simonw I think this is ready for a look.

@simonw
Copy link
Owner

simonw commented Feb 15, 2022

This PR looks fantastic.

@simonw
Copy link
Owner

simonw commented Feb 15, 2022

We should add SpatiaLite to the action that calculates code coverage - that way we can calculate coverage across the new GIS tests as well: https://github.com/simonw/sqlite-utils/blob/main/.github/workflows/test-coverage.yml

Should just be a case of adding this to that workflow - we can do this in the same PR.

    - name: Install SpatiaLite
      run: sudo apt-get install libsqlite3-mod-spatialite

@simonw
Copy link
Owner

simonw commented Feb 15, 2022

Wow, just found out I can edit files in this PR branch by hitting . on my keyboard while looking at the PR, then making changes in the VS Code for web on github.dev!

@simonw simonw merged commit a692c56 into simonw:main Feb 16, 2022
@simonw
Copy link
Owner

simonw commented Feb 16, 2022

This is honestly one of the most complete PRs I've ever seen for a feature of this size. Thanks so much for this!

@eyeseast
Copy link
Contributor Author

Happy to do it and have it in the library. Going to use it a bunch. This whole SpatiaLite toolchain become a huge part of my work in the past year.

simonw added a commit that referenced this pull request Feb 16, 2022
@simonw simonw added cli-tool enhancement New feature or request labels Feb 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli-tool enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add SpatiaLite helpers to CLI
2 participants