|
| 1 | +title: sqlalchemy.dialects.postgresql DOUBLE_PRECISION code examples |
| 2 | +category: page |
| 3 | +slug: sqlalchemy-dialects-postgresql-double-precision-examples |
| 4 | +sortorder: 500031008 |
| 5 | +toc: False |
| 6 | +sidebartitle: sqlalchemy.dialects.postgresql DOUBLE_PRECISION |
| 7 | +meta: Python example code for the DOUBLE_PRECISION constant from the sqlalchemy.dialects.postgresql module of the SQLAlchemy project. |
| 8 | + |
| 9 | + |
| 10 | +DOUBLE_PRECISION is a constant within the sqlalchemy.dialects.postgresql module of the SQLAlchemy project. |
| 11 | + |
| 12 | + |
| 13 | +## Example 1 from GeoAlchemy2 |
| 14 | +[GeoAlchemy2](https://github.com/geoalchemy/geoalchemy2) |
| 15 | +([project documentation](https://geoalchemy-2.readthedocs.io/en/latest/) |
| 16 | +and |
| 17 | +[PyPI package information](https://pypi.org/project/GeoAlchemy2/)) |
| 18 | +extends [SQLAlchemy](/sqlalchemy.html) with new data types for working |
| 19 | +with geospatial databases, particularly [PostGIS](http://postgis.net/), |
| 20 | +which is a spatial database extender for [PostgreSQL](/postgresql.html). |
| 21 | +The project is provided as open source under the |
| 22 | +[MIT license](https://github.com/geoalchemy/geoalchemy2/blob/master/COPYING.rst). |
| 23 | + |
| 24 | +[**GeoAlchemy2 / geoalchemy2 / comparator.py**](https://github.com/geoalchemy/geoalchemy2/blob/master/geoalchemy2/./comparator.py) |
| 25 | + |
| 26 | +```python |
| 27 | +# comparator.py |
| 28 | + |
| 29 | +from sqlalchemy import types as sqltypes |
| 30 | +from sqlalchemy.types import UserDefinedType |
| 31 | +~~from sqlalchemy.dialects.postgresql import DOUBLE_PRECISION |
| 32 | +from sqlalchemy.sql import operators |
| 33 | +try: |
| 34 | + from sqlalchemy.sql.functions import _FunctionGenerator |
| 35 | +except ImportError: # SQLA < 0.9 # pragma: no cover |
| 36 | + from sqlalchemy.sql.expression import _FunctionGenerator |
| 37 | + |
| 38 | + |
| 39 | +INTERSECTS = operators.custom_op('&&') |
| 40 | +OVERLAPS_OR_TO_LEFT = operators.custom_op('&<') |
| 41 | +OVERLAPS_OR_TO_RIGHT = operators.custom_op('&>') |
| 42 | +OVERLAPS_OR_BELOW = operators.custom_op('&<|') |
| 43 | +TO_LEFT = operators.custom_op('<<') |
| 44 | +BELOW = operators.custom_op('<<|') |
| 45 | +TO_RIGHT = operators.custom_op('>>') |
| 46 | +CONTAINED = operators.custom_op('@') |
| 47 | +OVERLAPS_OR_ABOVE = operators.custom_op('|&>') |
| 48 | +ABOVE = operators.custom_op('|>>') |
| 49 | +CONTAINS = operators.custom_op('-') |
| 50 | +SAME = operators.custom_op('-=') |
| 51 | +DISTANCE_CENTROID = operators.custom_op('<->') |
| 52 | +DISTANCE_BOX = operators.custom_op('<#>') |
| 53 | + |
| 54 | + |
| 55 | +class BaseComparator(UserDefinedType.Comparator): |
| 56 | + |
| 57 | + |
| 58 | +## ... source file continues with no further DOUBLE_PRECISION examples... |
| 59 | + |
| 60 | +``` |
| 61 | + |
0 commit comments