Skip to content

Latest commit

 

History

History
71 lines (55 loc) · 3.18 KB

File metadata and controls

71 lines (55 loc) · 3.18 KB

title: sqlalchemy.dialects.postgresql TSVECTOR Example Code category: page slug: sqlalchemy-dialects-postgresql-tsvector-examples sortorder: 500031014 toc: False sidebartitle: sqlalchemy.dialects.postgresql TSVECTOR meta: Python example code that shows how to use the TSVECTOR constant from the sqlalchemy.dialects.postgresql module of the SQLAlchemy project.

TSVECTOR is a constant within the sqlalchemy.dialects.postgresql module of the SQLAlchemy project.

ARRAY, BIGINT, BIT, DOUBLE_PRECISION, ExcludeConstraint, INTEGER, JSON, array, json, and pypostgresql are several other callables with code examples from the same sqlalchemy.dialects.postgresql package.

Example 1 from sqlalchemy-utils

sqlalchemy-utils (project documentation and PyPI package information) is a code library with various helper functions and new data types that make it easier to use SQLAlchemy when building projects that involve more specific storage requirements such as currency. The wide array of data types includes ranged values and aggregated attributes.

sqlalchemy-utils / sqlalchemy_utils / types / ts_vector.py

# ts_vector.py
import sqlalchemy as sa
~~from sqlalchemy.dialects.postgresql import TSVECTOR


class TSVectorType(sa.types.TypeDecorator):
    impl = TSVECTOR

    class comparator_factory(TSVECTOR.Comparator):
        def match(self, other, **kwargs):
            if 'postgresql_regconfig' not in kwargs:
                if 'regconfig' in self.type.options:
                    kwargs['postgresql_regconfig'] = (
                        self.type.options['regconfig']
                    )
~~            return TSVECTOR.Comparator.match(self, other, **kwargs)

        def __or__(self, other):
            return self.op('||')(other)

    def __init__(self, *args, **kwargs):
        self.columns = args
        self.options = kwargs
        super(TSVectorType, self).__init__()



## ... source file continues with no further TSVECTOR examples...