我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用sqlalchemy.sql.expression._TextClause()。
def _get_compiled_expression(statement): """Returns the statement in a form where any placeholders have been filled in.""" if isinstance(statement, TextClause): return statement.text dialect = statement._from_objects[0].bind.dialect compiler = statement._compiler(dialect) # Adapted from http://stackoverflow.com/a/5698357/242021 class LiteralCompiler(compiler.__class__): def visit_bindparam(self, bindparam, within_columns_clause=False, literal_binds=False, **kwargs): return super(LiteralCompiler, self).render_literal_bindparam( bindparam, within_columns_clause=within_columns_clause, literal_binds=literal_binds, **kwargs ) compiler = LiteralCompiler(dialect, statement) return compiler.process(statement)
def _textual_index_column(table, text_): """a workaround for the Index construct's severe lack of flexibility""" if isinstance(text_, compat.string_types): c = Column(text_, sqltypes.NULLTYPE) table.append_column(c) return c elif isinstance(text_, TextClause): return _textual_index_element(table, text_) else: raise ValueError("String or text() construct expected")
def _textual_index_column(table, text_): """a workaround for the Index construct's severe lack of flexibility""" if isinstance(text_, string_types): c = schema.Column(text_, sqltypes.NULLTYPE) table.append_column(c) return c elif isinstance(text_, TextClause): return _textual_index_element(table, text_) else: raise ValueError("String or text() construct expected")