summaryrefslogtreecommitdiff
path: root/examples/postgis/postgis.py
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2020-09-02 23:46:06 +0200
committerMike Bayer <mike_mp@zzzcomputing.com>2020-09-08 17:13:48 -0400
commite8600608669d90c4a6385b312d271aed63eb5854 (patch)
treeef984a01c536b2c81d2283b3ca5d9f4395f41dd0 /examples/postgis/postgis.py
parent0d56a62f721ee6c91d8a8b6a407b959c9215b3b6 (diff)
downloadsqlalchemy-e8600608669d90c4a6385b312d271aed63eb5854.tar.gz
Update select usage to use the new 1.4 format
This change includes mainly that the bracketed use within select() is moved to positional, and keyword arguments are removed from calls to the select() function. it does not yet fully address other issues such as keyword arguments passed to the table.select(). Additionally, allows False / None to both be considered as "disable" for all of select.correlate(), select.correlate_except(), query.correlate(), which establishes consistency with passing of ``False`` for the legact select(correlate=False) argument. Change-Id: Ie6c6e6abfbd3d75d4c8de504c0cf0159e6999108
Diffstat (limited to 'examples/postgis/postgis.py')
-rw-r--r--examples/postgis/postgis.py36
1 files changed, 15 insertions, 21 deletions
diff --git a/examples/postgis/postgis.py b/examples/postgis/postgis.py
index 868d3d055..a12b824ba 100644
--- a/examples/postgis/postgis.py
+++ b/examples/postgis/postgis.py
@@ -190,13 +190,10 @@ def setup_ddl_events():
for c in gis_cols:
bind.execute(
select(
- [
- func.DropGeometryColumn(
- "public", table.name, c.name
- )
- ],
- autocommit=True,
- )
+ func.DropGeometryColumn(
+ "public", table.name, c.name
+ )
+ ).execution_options(autocommit=True)
)
elif event == "after-create":
@@ -205,17 +202,14 @@ def setup_ddl_events():
if isinstance(c.type, Geometry):
bind.execute(
select(
- [
- func.AddGeometryColumn(
- table.name,
- c.name,
- c.type.srid,
- c.type.name,
- c.type.dimension,
- )
- ],
- autocommit=True,
- )
+ func.AddGeometryColumn(
+ table.name,
+ c.name,
+ c.type.srid,
+ c.type.name,
+ c.type.dimension,
+ )
+ ).execution_options(autocommit=True)
)
elif event == "after-drop":
table.columns = table.info.pop("_saved_columns")
@@ -319,7 +313,7 @@ if __name__ == "__main__":
# core usage just fine:
road_table = Road.__table__
- stmt = select([road_table]).where(
+ stmt = select(road_table).where(
road_table.c.road_geom.intersects(r1.road_geom)
)
print(session.execute(stmt).fetchall())
@@ -329,7 +323,7 @@ if __name__ == "__main__":
# look up the hex binary version, using SQLAlchemy casts
as_binary = session.scalar(
- select([type_coerce(r.road_geom, Geometry(coerce_="binary"))])
+ select(type_coerce(r.road_geom, Geometry(coerce_="binary")))
)
assert as_binary.as_hex == (
"01020000000200000000000000b832084100000000"
@@ -338,7 +332,7 @@ if __name__ == "__main__":
# back again, same method !
as_text = session.scalar(
- select([type_coerce(as_binary, Geometry(coerce_="text"))])
+ select(type_coerce(as_binary, Geometry(coerce_="text")))
)
assert as_text.desc == "LINESTRING(198231 263418,198213 268322)"