mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-17 14:04:11 +02:00
Make GIS helpers into methods on Database and Table. Remove gis.py.
This commit is contained in:
parent
a3639f39d9
commit
481eb60a1b
7 changed files with 179 additions and 186 deletions
|
|
@ -22,8 +22,38 @@ except ImportError:
|
|||
|
||||
OperationalError = sqlite3.OperationalError
|
||||
|
||||
# backwards compatibility
|
||||
from .gis import find_spatialite
|
||||
|
||||
SPATIALITE_PATHS = (
|
||||
"/usr/lib/x86_64-linux-gnu/mod_spatialite.so",
|
||||
"/usr/local/lib/mod_spatialite.dylib",
|
||||
)
|
||||
|
||||
|
||||
def find_spatialite() -> str:
|
||||
"""
|
||||
The ``find_spatialite()`` function searches for the `SpatiaLite <https://www.gaia-gis.it/fossil/libspatialite/index>`__ SQLite extension in some common places. It returns a string path to the location, or ``None`` if SpatiaLite was not found.
|
||||
|
||||
You can use it in code like this:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from sqlite_utils import Database
|
||||
from sqlite_utils.utils import find_spatialite
|
||||
|
||||
db = Database("mydb.db")
|
||||
spatialite = find_spatialite()
|
||||
if spatialite:
|
||||
db.conn.enable_load_extension(True)
|
||||
db.conn.load_extension(spatialite)
|
||||
|
||||
# or use with db.init_spatialite like this
|
||||
db.init_spatialite(find_spatialite())
|
||||
|
||||
"""
|
||||
for path in SPATIALITE_PATHS:
|
||||
if os.path.exists(path):
|
||||
return path
|
||||
return None
|
||||
|
||||
|
||||
def suggest_column_types(records):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue