当前位置: 首页>>代码示例>>Python>>正文


Python dialect.DialectManager类代码示例

本文整理汇总了Python中geoalchemy.dialect.DialectManager的典型用法代码示例。如果您正苦于以下问题:Python DialectManager类的具体用法?Python DialectManager怎么用?Python DialectManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DialectManager类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __call__

    def __call__(self, event, table, bind):
        spatial_dialect = DialectManager.get_spatial_dialect(bind.dialect)
        if event in ('before-create', 'before-drop'):
            """Remove geometry column from column list (table._columns), so that it 
            does not show up in the create statement ("create table tab (..)"). 
            Afterwards (on event 'after-create') restore the column list from self._stack.
            """
            regular_cols = [c for c in table.c if not isinstance(c.type, Geometry)]
            gis_cols = set(table.c).difference(regular_cols)
            self._stack.append(table.c)
            setattr(table, self.columns_attribute,
                    expression.ColumnCollection(*regular_cols))
            
            if event == 'before-drop':
                for c in gis_cols:
                    spatial_dialect.handle_ddl_before_drop(bind, table, c)
                
        elif event == 'after-create':
            setattr(table, self.columns_attribute, self._stack.pop())
            
            for c in table.c:
                if isinstance(c.type, Geometry):
                    spatial_dialect.handle_ddl_after_create(bind, table, c)

        elif event == 'after-drop':
            setattr(table, self.columns_attribute, self._stack.pop())
开发者ID:blackrez,项目名称:geoalchemy,代码行数:26,代码来源:geometry.py

示例2: __compile_wkbspatialelement

def __compile_wkbspatialelement(element, compiler, **kw):
    from geoalchemy.dialect import DialectManager 
    database_dialect = DialectManager.get_spatial_dialect(compiler.dialect)
    function = _get_function(element, compiler, (database_dialect.bind_wkb_value(element), 
                                                 element.srid),
                                                 kw.get('within_columns_clause', False))
    return compiler.process(function)
开发者ID:vuamitom,项目名称:geoalchemy,代码行数:7,代码来源:base.py

示例3: _get_function

def _get_function(element, compiler, params, within_column_clause):
    """For elements of type BaseFunction, the database specific function data 
    is looked up and a executable sqlalchemy.sql.expression.Function object 
    is returned.
    """
    from geoalchemy.dialect import DialectManager 
    database_dialect = DialectManager.get_spatial_dialect(compiler.dialect)
    for kls in element.__class__.__mro__:
        try:
            function_data = database_dialect.get_function(kls)
        except KeyError:
            continue
    if function_data is None:
        raise Exception("Unsupported function for this dialect")
    
    if isinstance(function_data, list):
        """if we have a list of function names, create cascaded Function objects
        for all function names in the list::
        
            ['TO_CHAR', 'SDO_UTIL.TO_WKTGEOMETRY'] --> TO_CHAR(SDO_UTIL.TO_WKTGEOMETRY(..))
        """
        function = None
        for name in reversed(function_data):
            packages = name.split('.')
            
            if function is None:
                """for the innermost function use the passed-in parameters as argument,
                otherwise use the prior created function
                """
                args = params
            else:
                args = [function]
                
            function = Function(packages.pop(-1), 
                        packagenames=packages,
                        *args
                        )
        
        return function
    
    elif isinstance(function_data, types.FunctionType):
        """if we have a function, call this function with the parameters and return the
        created Function object
        """
        if hasattr(element, 'flags'):
            # when element is a BaseFunction
            flags = element.flags
        else:
            flags = {}
            
        return function_data(params, within_column_clause, **flags)
    
    else:
        packages = function_data.split('.')
        
        return Function(packages.pop(-1), 
                        packagenames=packages, 
                        *params
                        )
开发者ID:gzb1985,项目名称:fun_projects,代码行数:59,代码来源:functions.py

示例4: process_result_value

 def process_result_value(self, value, dialect):
     if value is not None:
         from geoalchemy.dialect import DialectManager 
         database_dialect = DialectManager.get_spatial_dialect(dialect)
         
         return database_dialect.process_wkb(value)
     else:
         return value
开发者ID:GunioRobot,项目名称:geoalchemy,代码行数:8,代码来源:functions.py

示例5: __compile__within_distance

def __compile__within_distance(element, compiler, **kw):
    from geoalchemy.dialect import DialectManager 
    database_dialect = DialectManager.get_spatial_dialect(compiler.dialect)
    function = database_dialect.get_function(element.__class__)
    arguments = list(element.arguments)
    return compiler.process(
        function(compiler,
                 parse_clause(arguments.pop(0), compiler),
                 parse_clause(arguments.pop(0), compiler),
                 arguments.pop(0), *arguments))
开发者ID:GunioRobot,项目名称:geoalchemy,代码行数:10,代码来源:functions.py

示例6: test_get_spatial_dialect

 def test_get_spatial_dialect(self):
     spatial_dialect = DialectManager.get_spatial_dialect(PGDialect_psycopg2())
     ok_(isinstance(spatial_dialect, PGSpatialDialect))
     ok_(isinstance(DialectManager.get_spatial_dialect(MySQLDialect()), MySQLSpatialDialect))
     ok_(isinstance(DialectManager.get_spatial_dialect(SQLiteDialect()), SQLiteSpatialDialect))
     ok_(isinstance(DialectManager.get_spatial_dialect(OracleDialect()), OracleSpatialDialect))
     ok_(isinstance(DialectManager.get_spatial_dialect(MSDialect()), MSSpatialDialect))
     spatial_dialect2 = DialectManager.get_spatial_dialect(PGDialect_psycopg2())
     ok_(spatial_dialect is spatial_dialect2, "only one instance per dialect should be created")
开发者ID:GunioRobot,项目名称:geoalchemy,代码行数:9,代码来源:test_dialect.py

示例7: __compile__within_distance

def __compile__within_distance(element, compiler, **kw):
    from geoalchemy.dialect import DialectManager 
    database_dialect = DialectManager.get_spatial_dialect(compiler.dialect)
    for kls in element.__class__.__mro__:
        try:
            function = database_dialect.get_function(kls)
        except KeyError:
            continue
    if function is None:
        raise Exception("Unsupported function for this dialect")
    arguments = list(element.arguments)
    return compiler.process(
        function(compiler,
                 parse_clause(arguments.pop(0), compiler),
                 parse_clause(arguments.pop(0), compiler),
                 arguments.pop(0), *arguments))
开发者ID:gzb1985,项目名称:fun_projects,代码行数:16,代码来源:functions.py

示例8: __compile_base_function

def __compile_base_function(element, compiler, **kw):
    
    params = [parse_clause(argument, compiler) for argument in element.arguments]
    
    from geoalchemy.dialect import DialectManager 
    database_dialect = DialectManager.get_spatial_dialect(compiler.dialect)
    
    if database_dialect.is_member_function(element.__class__):
        geometry = params.pop(0)
        function_name = database_dialect.get_function(element.__class__)
        
        if isinstance(function_name, str):
            """If the function is defined as String (e.g. "oracle_functions.dims : 'Get_Dims'"), 
            we construct the function call in the query ourselves. This is because SQLAlchemy, 
            at this point of the compile process, does not add parenthesis for functions 
            without arguments when using Oracle.
            Otherwise let SQLAlchemy build the query. Note that this won't work for Oracle with
            functions without parameters."""
            
            return "%s.%s(%s)" % (
                        compiler.process(geometry),
                        function_name,
                        ", ".join([compiler.process(e) for e in params]) 
                        )
        else:
            function = _get_function(element, compiler, params, kw.get('within_columns_clause', False))
            
            return "%s.%s" % (
                        compiler.process(geometry),
                        compiler.process(function)      
                        )
            
    elif database_dialect.is_property(element.__class__):
        geometry = params.pop(0)
        function_name = database_dialect.get_function(element.__class__)
        
        return "%s.%s" % (
                        compiler.process(geometry),
                        function_name 
                        )
        
    else:
        function = _get_function(element, compiler, params, kw.get('within_columns_clause', False))
        return compiler.process(function)
开发者ID:GunioRobot,项目名称:geoalchemy,代码行数:44,代码来源:functions.py

示例9: process

 def process(value):
     if value is not None:
         return DialectManager.get_spatial_dialect(dialect).process_result(value, self)
     else:
         return value
开发者ID:blackrez,项目名称:geoalchemy,代码行数:5,代码来源:geometry.py

示例10: test_get_spatial_dialect_unknown_dialect

 def test_get_spatial_dialect_unknown_dialect(self):
     DialectManager.get_spatial_dialect(FBDialect())
开发者ID:GunioRobot,项目名称:geoalchemy,代码行数:2,代码来源:test_dialect.py


注:本文中的geoalchemy.dialect.DialectManager类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。