diff --git a/.gitignore b/.gitignore
index 37fe67c..d708a34 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,7 @@ var/
*.egg-info/
.installed.cfg
*.egg
+venv
# PyInstaller
# Usually these files are written by a python script from a template
diff --git a/CHANGES.rst b/CHANGES.rst
index 77c3b6f..2b7a82e 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on `Keep a Changelog `_, and this project adheres to `Semantic Versioning `_.
+Version 0.6.2
+------------------
+
+Released on September 13th 2024
+
+Added
+-----
+- Geometry field in sqlalchemy
Version 0.6.1.dev0
------------------
diff --git a/dbcut/__init__.py b/dbcut/__init__.py
index e935144..a613b63 100755
--- a/dbcut/__init__.py
+++ b/dbcut/__init__.py
@@ -3,6 +3,6 @@
from .compiler import * # noqa
-__version__ = "0.6.1.dev0"
+__version__ = "0.6.2"
VERSION = __version__
SQLALCHEMY_VERSION = sqlalchemy.__version__
diff --git a/dbcut/database.py b/dbcut/database.py
index ca5f1ee..da1d0a4 100644
--- a/dbcut/database.py
+++ b/dbcut/database.py
@@ -9,6 +9,7 @@
from contextlib import contextmanager
import sqlalchemy
+from geoalchemy2 import Geometry
from sqlalchemy import MetaData, Table, create_engine, event, func, inspect
from sqlalchemy.engine.url import make_url
from sqlalchemy.ext.automap import automap_base, generate_relationship
@@ -21,8 +22,13 @@
from .models import BaseDeclarativeMeta, BaseModel
from .query import BaseQuery, QueryProperty
from .session import SessionProperty
-from .utils import (aslist, cached_property, create_directory,
- generate_valid_index_name, to_unicode)
+from .utils import (
+ aslist,
+ cached_property,
+ create_directory,
+ generate_valid_index_name,
+ to_unicode,
+)
try:
from easy_profile import SessionProfiler, StreamReporter
diff --git a/dbcut/serializer.py b/dbcut/serializer.py
index 8b807e4..06e3917 100644
--- a/dbcut/serializer.py
+++ b/dbcut/serializer.py
@@ -7,6 +7,8 @@
from io import open
import yaml
+from geoalchemy2 import WKBElement
+from geoalchemy2.shape import to_shape
from sqlalchemy.orm import Query
from .utils import to_unicode
@@ -49,6 +51,8 @@ def default(self, obj):
pass
elif hasattr(obj, "__iter__"):
return list(item for item in obj)
+ elif isinstance(obj, WKBElement):
+ return str(to_shape(obj))
return super(JSONEncoder, self).default(obj)
return JSONEncoder
diff --git a/requirements/base.txt b/requirements/base.txt
index 1d9ab4c..073fd96 100644
--- a/requirements/base.txt
+++ b/requirements/base.txt
@@ -1,6 +1,8 @@
Click
-SQLAlchemy
+sqlalchemy<2.0
mlalchemy
+geoalchemy2
+shapely
pptree
python-dotenv
tabulate
diff --git a/scripts/run-test-with-docker.sh b/scripts/run-test-with-docker.sh
index e7dfe93..f2207ac 100755
--- a/scripts/run-test-with-docker.sh
+++ b/scripts/run-test-with-docker.sh
@@ -1,6 +1,13 @@
#!/usr/bin/env bash
ROOT_PROJECT="$(dirname "$(dirname "${BASH_SOURCE[0]}")")"
+if ! command -v "docker-compose" >/dev/null
+then
+ compose="docker compose"
+else
+ compose="docker-compose"
+fi
+
export PYTHON_IMAGE=${PYTHON_IMAGE:-python:3.6}
export POSTGRES_IMAGE=${POSTGRES_IMAGE:-postgres:9.6}
@@ -34,7 +41,7 @@ _print() { printf "\033[1;32m%b\033[0m\n" "$1"; }
_cleanup() {
_print ":: Cleanup"
- docker-compose down -v --remove-orphans
+ $compose down -v --remove-orphans
}
if [ "$1" = "cleanup" ]; then
@@ -46,8 +53,8 @@ else
_cleanup
_print ":: Building image"
- docker-compose build
+ $compose build
_print ":: Running tests"
- docker-compose run --rm app make test
+ $compose run --rm app make test
fi