summaryrefslogtreecommitdiff
path: root/examples/postgis/postgis.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/postgis/postgis.py')
-rw-r--r--examples/postgis/postgis.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/examples/postgis/postgis.py b/examples/postgis/postgis.py
index 508d63398..868d3d055 100644
--- a/examples/postgis/postgis.py
+++ b/examples/postgis/postgis.py
@@ -1,8 +1,12 @@
-from sqlalchemy.types import UserDefinedType, _Binary, TypeDecorator
-from sqlalchemy.sql import expression, type_coerce
-from sqlalchemy import event, Table
import binascii
+from sqlalchemy import event
+from sqlalchemy import Table
+from sqlalchemy.sql import expression
+from sqlalchemy.sql import type_coerce
+from sqlalchemy.types import UserDefinedType
+
+
# Python datatypes
@@ -278,7 +282,8 @@ if __name__ == "__main__":
]
)
- # or use an explicit TextualGisElement (similar to saying func.GeomFromText())
+ # or use an explicit TextualGisElement
+ # (similar to saying func.GeomFromText())
r = Road(
road_name="Dave Cres",
road_geom=TextualGisElement(
@@ -292,7 +297,8 @@ if __name__ == "__main__":
session.commit()
- # after flush and/or commit, all the TextualGisElements become PersistentGisElements.
+ # after flush and/or commit, all the TextualGisElements
+ # become PersistentGisElements.
assert str(r.road_geom) == "LINESTRING(198231 263418,198213 268322)"
r1 = session.query(Road).filter(Road.road_name == "Graeme Ave").one()
@@ -318,16 +324,16 @@ if __name__ == "__main__":
)
print(session.execute(stmt).fetchall())
- # TODO: for some reason the auto-generated labels have the internal replacement
- # strings exposed, even though PG doesn't complain
+ # TODO: for some reason the auto-generated labels have the internal
+ # replacement strings exposed, even though PG doesn't complain
# look up the hex binary version, using SQLAlchemy casts
as_binary = session.scalar(
select([type_coerce(r.road_geom, Geometry(coerce_="binary"))])
)
- assert (
- as_binary.as_hex
- == "01020000000200000000000000b832084100000000e813104100000000283208410000000088601041"
+ assert as_binary.as_hex == (
+ "01020000000200000000000000b832084100000000"
+ "e813104100000000283208410000000088601041"
)
# back again, same method !