GeoAlchemy2 0.13.0__py3-none-any.whl → 0.13.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: GeoAlchemy2
3
- Version: 0.13.0
3
+ Version: 0.13.2
4
4
  Summary: Using SQLAlchemy with Spatial Databases
5
5
  Home-page: https://geoalchemy-2.readthedocs.io/en/latest/
6
6
  Author: Eric Lemoine
@@ -0,0 +1,18 @@
1
+ geoalchemy2/__init__.py,sha256=osB4UEZhXaj5uscV-Nzy1bXroSBw9MTAmGTM1g97iTc,4874
2
+ geoalchemy2/_functions.py,sha256=JdZdgGgRrjv7EySEEHfo1WDIJaGyldTqpCD6jUXVzEQ,62680
3
+ geoalchemy2/alembic_helpers.py,sha256=zNuiBTv-zBgv-tU_F6RK6qdv9If5UlzHZpAJUrqjxhU,24834
4
+ geoalchemy2/comparator.py,sha256=1GkzKi2-kmHPjwoTxMgGGEzMChlo3_XXEv_Vm9-YKIg,7277
5
+ geoalchemy2/elements.py,sha256=XOEJUfzHiULxFflLyrlvm-korIA9wvAz3CHSrHsIrWg,8032
6
+ geoalchemy2/exc.py,sha256=Nn9bRKB_35skWDMkEf4_Y2GL6gvguPVycPZcbOfa69g,226
7
+ geoalchemy2/functions.py,sha256=BhT_tRBxQw9k4pMaDwR9gICo7tmgwTtbyZGsoPq8_x4,10037
8
+ geoalchemy2/shape.py,sha256=uLs2vCW7VnSsaS58f43bg60VjuyoEr9Eq_g7pMGI4-0,3432
9
+ geoalchemy2/types.py,sha256=F8Qa7ZsDgOB7wjawlgpsJPtzhaTOFNjWdmWlByQ9emU,16733
10
+ geoalchemy2/dialects/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
+ geoalchemy2/dialects/common.py,sha256=5fC6w59JtAkqigkq01TBaQo5teGmknfYA0wyvXeHpEs,2744
12
+ geoalchemy2/dialects/postgresql.py,sha256=btr-a5ckQRXoEUZCCddoyPAyl2bqTZQuuvRllrAtDCQ,6751
13
+ geoalchemy2/dialects/sqlite.py,sha256=g4frIyZYGzalhi_PlPOnDUvkeIDJ0KObgjwWH9JkY2g,9253
14
+ GeoAlchemy2-0.13.2.dist-info/COPYING.rst,sha256=-bQKftq9uMOROzF7oN65kYBBIJKxTmBuDoftp27IC3I,1056
15
+ GeoAlchemy2-0.13.2.dist-info/METADATA,sha256=T_VK6Fuyzg21OLIlD8EC2S3nUTNEdHmhZ4iw8fvRg1A,1751
16
+ GeoAlchemy2-0.13.2.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
17
+ GeoAlchemy2-0.13.2.dist-info/top_level.txt,sha256=3kGUTcfBeXd61zFpof6-qiuw1peNF_HuZabgHQgrdis,12
18
+ GeoAlchemy2-0.13.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.38.4)
2
+ Generator: bdist_wheel (0.40.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
geoalchemy2/__init__.py CHANGED
@@ -7,6 +7,7 @@ from sqlalchemy.sql import func
7
7
 
8
8
  from geoalchemy2 import functions # noqa
9
9
  from geoalchemy2 import types # noqa
10
+ from geoalchemy2.dialects import common
10
11
  from geoalchemy2.dialects import postgresql
11
12
  from geoalchemy2.dialects import sqlite
12
13
  from geoalchemy2.dialects.common import _check_spatial_type
@@ -27,12 +28,7 @@ def _select_dialect(dialect_name):
27
28
  "postgresql": postgresql,
28
29
  "sqlite": sqlite,
29
30
  }
30
- try:
31
- return known_dialects[dialect_name]
32
- except KeyError:
33
- raise ValueError(
34
- f"The dialect '{dialect_name}' is unknown, please choose one of {known_dialects.keys()}"
35
- )
31
+ return known_dialects.get(dialect_name, common)
36
32
 
37
33
 
38
34
  def _setup_ddl_event_listeners():
@@ -41,11 +41,14 @@ def _monkey_patch_get_indexes_for_sqlite():
41
41
  def spatial_behavior(self, connection, table_name, schema=None, **kw):
42
42
  indexes = self._get_indexes_normal_behavior(connection, table_name, schema=None, **kw)
43
43
 
44
- # Check that SpatiaLite was loaded into the DB
45
- is_spatial_db = connection.exec_driver_sql(
46
- """PRAGMA main.table_info(geometry_columns)"""
47
- ).fetchall()
48
- if not is_spatial_db:
44
+ try:
45
+ # Check that SpatiaLite was loaded into the DB
46
+ is_spatial_db = connection.exec_driver_sql(
47
+ """PRAGMA main.table_info(geometry_columns)"""
48
+ ).fetchall()
49
+ if not is_spatial_db:
50
+ return indexes
51
+ except AttributeError:
49
52
  return indexes
50
53
 
51
54
  # Get spatial indexes
geoalchemy2/comparator.py CHANGED
@@ -77,7 +77,6 @@ class BaseComparator(UserDefinedType.Comparator):
77
77
  key = None
78
78
 
79
79
  def __getattr__(self, name):
80
-
81
80
  # Function names that don't start with "ST_" are rejected.
82
81
  # This is not to mess up with SQLAlchemy's use of
83
82
  # hasattr/getattr on Column objects.
@@ -2,9 +2,11 @@
2
2
  import os
3
3
 
4
4
  from sqlalchemy import text
5
+ from sqlalchemy.ext.compiler import compiles
5
6
  from sqlalchemy.sql import func
6
7
  from sqlalchemy.sql import select
7
8
 
9
+ from geoalchemy2 import functions
8
10
  from geoalchemy2.dialects.common import _check_spatial_type
9
11
  from geoalchemy2.dialects.common import _format_select_args
10
12
  from geoalchemy2.dialects.common import _spatial_idx_name
@@ -185,8 +187,7 @@ def after_create(table, bind, **kw):
185
187
  col.type = col._actual_type
186
188
  del col._actual_type
187
189
  dimension = get_col_dim(col)
188
- args = [table.schema] if table.schema else []
189
- args.extend([table.name, col.name, col.type.srid, col.type.geometry_type, dimension])
190
+ args = [table.name, col.name, col.type.srid, col.type.geometry_type, dimension]
190
191
 
191
192
  stmt = select(*_format_select_args(func.RecoverGeometryColumn(*args)))
192
193
  stmt = stmt.execution_options(autocommit=True)
@@ -211,8 +212,7 @@ def before_drop(table, bind, **kw):
211
212
  # Disable spatial indexes if present
212
213
  disable_spatial_index(bind, table, col)
213
214
 
214
- args = [table.schema] if table.schema else []
215
- args.extend([table.name, col.name])
215
+ args = [table.name, col.name]
216
216
 
217
217
  stmt = select(*_format_select_args(func.DiscardGeometryColumn(*args)))
218
218
  stmt = stmt.execution_options(autocommit=True)
@@ -222,3 +222,40 @@ def before_drop(table, bind, **kw):
222
222
  def after_drop(table, bind, **kw):
223
223
  """Handle spatial indexes during the after_drop event."""
224
224
  table.columns = table.info.pop("_saved_columns")
225
+
226
+
227
+ # Define compiled versions for functions in SpatiaLite whose names don't have
228
+ # the ST_ prefix.
229
+ _SQLITE_FUNCTIONS = {
230
+ "ST_GeomFromEWKT": "GeomFromEWKT",
231
+ "ST_GeomFromEWKB": "GeomFromEWKB",
232
+ "ST_AsBinary": "AsBinary",
233
+ "ST_AsEWKB": "AsEWKB",
234
+ "ST_AsGeoJSON": "AsGeoJSON",
235
+ }
236
+
237
+
238
+ def _compiles_sqlite(cls, fn):
239
+ def _compile_sqlite(element, compiler, **kw):
240
+ return "{}({})".format(fn, compiler.process(element.clauses, **kw))
241
+
242
+ compiles(getattr(functions, cls), "sqlite")(_compile_sqlite)
243
+
244
+
245
+ def register_sqlite_mapping(mapping):
246
+ """Register compilation mappings for the given functions.
247
+
248
+ Args:
249
+ mapping: Should have the following form::
250
+
251
+ {
252
+ "function_name_1": "sqlite_function_name_1",
253
+ "function_name_2": "sqlite_function_name_2",
254
+ ...
255
+ }
256
+ """
257
+ for cls, fn in mapping.items():
258
+ _compiles_sqlite(cls, fn)
259
+
260
+
261
+ register_sqlite_mapping(_SQLITE_FUNCTIONS)
geoalchemy2/functions.py CHANGED
@@ -125,7 +125,6 @@ except ImportError:
125
125
 
126
126
 
127
127
  class TableRowElement(ColumnElement):
128
-
129
128
  inherit_cache = False
130
129
  """The cache is disabled for this class."""
131
130
 
@@ -278,54 +277,3 @@ for name, type_, doc in _FUNCTIONS:
278
277
  attributes["__doc__"] = "\n\n".join(docs)
279
278
 
280
279
  globals()[name] = type(name, (GenericFunction,), attributes)
281
-
282
-
283
- #
284
- # Define compiled versions for functions in SpatiaLite whose names don't have
285
- # the ST_ prefix.
286
- #
287
-
288
-
289
- _SQLITE_FUNCTIONS = {
290
- "ST_GeomFromEWKT": "GeomFromEWKT",
291
- "ST_GeomFromEWKB": "GeomFromEWKB",
292
- "ST_AsBinary": "AsBinary",
293
- "ST_AsEWKB": "AsEWKB",
294
- "ST_AsGeoJSON": "AsGeoJSON",
295
- }
296
-
297
-
298
- # Default handlers are required for SQLAlchemy < 1.1
299
- # See more details in https://github.com/geoalchemy/geoalchemy2/issues/213
300
- def _compiles_default(cls):
301
- def _compile_default(element, compiler, **kw):
302
- return "{}({})".format(cls, compiler.process(element.clauses, **kw))
303
-
304
- compiles(globals()[cls])(_compile_default)
305
-
306
-
307
- def _compiles_sqlite(cls, fn):
308
- def _compile_sqlite(element, compiler, **kw):
309
- return "{}({})".format(fn, compiler.process(element.clauses, **kw))
310
-
311
- compiles(globals()[cls], "sqlite")(_compile_sqlite)
312
-
313
-
314
- def register_sqlite_mapping(mapping):
315
- """Register compilation mappings for the given functions.
316
-
317
- Args:
318
- mapping: Should have the following form::
319
-
320
- {
321
- "function_name_1": "sqlite_function_name_1",
322
- "function_name_2": "sqlite_function_name_2",
323
- ...
324
- }
325
- """
326
- for cls, fn in mapping.items():
327
- _compiles_default(cls)
328
- _compiles_sqlite(cls, fn)
329
-
330
-
331
- register_sqlite_mapping(_SQLITE_FUNCTIONS)
@@ -1,18 +0,0 @@
1
- geoalchemy2/__init__.py,sha256=IITvj3qQD8kyhaOJ_1YLn_iqebkPPNxaXBZh8HxLzGI,4993
2
- geoalchemy2/_functions.py,sha256=JdZdgGgRrjv7EySEEHfo1WDIJaGyldTqpCD6jUXVzEQ,62680
3
- geoalchemy2/alembic_helpers.py,sha256=f_AWdeONENrOZZVyA7hZgfacQUJq-J9y4opcv8KldkM,24739
4
- geoalchemy2/comparator.py,sha256=tOkIZ7bSuxbkAZXeqrG8lpSnCPH2u2c4MYbKwHaCXmE,7278
5
- geoalchemy2/elements.py,sha256=XOEJUfzHiULxFflLyrlvm-korIA9wvAz3CHSrHsIrWg,8032
6
- geoalchemy2/exc.py,sha256=Nn9bRKB_35skWDMkEf4_Y2GL6gvguPVycPZcbOfa69g,226
7
- geoalchemy2/functions.py,sha256=dKAOHEJjLALdF4DjubVkfs8KHzmh4RZVlceYND0xZhA,11393
8
- geoalchemy2/shape.py,sha256=uLs2vCW7VnSsaS58f43bg60VjuyoEr9Eq_g7pMGI4-0,3432
9
- geoalchemy2/types.py,sha256=F8Qa7ZsDgOB7wjawlgpsJPtzhaTOFNjWdmWlByQ9emU,16733
10
- geoalchemy2/dialects/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- geoalchemy2/dialects/common.py,sha256=5fC6w59JtAkqigkq01TBaQo5teGmknfYA0wyvXeHpEs,2744
12
- geoalchemy2/dialects/postgresql.py,sha256=btr-a5ckQRXoEUZCCddoyPAyl2bqTZQuuvRllrAtDCQ,6751
13
- geoalchemy2/dialects/sqlite.py,sha256=uNM028igtOK38NUeOTcxgGrHivFsmHZZcmSDHIpXArI,8305
14
- GeoAlchemy2-0.13.0.dist-info/COPYING.rst,sha256=-bQKftq9uMOROzF7oN65kYBBIJKxTmBuDoftp27IC3I,1056
15
- GeoAlchemy2-0.13.0.dist-info/METADATA,sha256=R4ZnsB8ImgxtiU5tbPKiOvYQD9DcQCphaS_pnaFe7Gs,1751
16
- GeoAlchemy2-0.13.0.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
17
- GeoAlchemy2-0.13.0.dist-info/top_level.txt,sha256=3kGUTcfBeXd61zFpof6-qiuw1peNF_HuZabgHQgrdis,12
18
- GeoAlchemy2-0.13.0.dist-info/RECORD,,