Ejemplo n.º 1
0
 def do_executemany(self, cursor, statement, parameters, context=None):
     try:
         stmt = context.compiled._panda_fn
     except AttributeError:
         raise exc.StatementError(
             "Only Pandas-compiled statements can be "
             "executed by this dialect", statement, parameters, None)
     cursor.executemany(stmt, parameters)
Ejemplo n.º 2
0
def sqlite_regex_match(element, compiler, **kw):
    """Compile the SQL expression representing a regular expression match
    for the SQLite engine.
    """
    # determine the name of a custom SQLite function to use for the operator
    operator = element.operator.opstring
    try:
        func_name, _ = SQLITE_REGEX_FUNCTIONS[operator]
    except (KeyError, ValueError), e:
        would_be_sql_string = ' '.join(
            (compiler.process(element.left), operator,
             compiler.process(element.right)))
        raise exc.StatementError(
            "unknown regular expression match operator: %s" % operator,
            would_be_sql_string, None, e)
Ejemplo n.º 3
0
def sqlite_regex_match(element, compiler, **kw):
    """Compile the SQL expression representing a regular expression match for the SQLite engine."""
    # determine the name of a custom SQLite function to use for the operator
    operator = element.operator.opstring
    try:
        func_name, _ = SQLITE_REGEX_FUNCTIONS[operator]
    except (KeyError, ValueError) as e:
        would_be_sql_string = ' '.join(
            (compiler.process(element.left), operator,
             compiler.process(element.right)))
        raise exc.StatementError(
            f"unknown regular expression match operator: {operator} {would_be_sql_string} {e}"
        )

    # compile the expression as an invocation of the custom function
    regex_func = getattr(func, func_name)
    regex_func_call = regex_func(element.left, element.right)
    return compiler.process(regex_func_call)
Ejemplo n.º 4
0
def sqlite_regex_match(element, compiler, **kw):
    operator = element.operator.opstring

    try:
        func_name, _ = SQLITE_REGEX_FUNCTIONS[operator]

    except (KeyError, ValueError) as e:
        would_be_sql_string = ' '.join((
            compiler.process(element.left),
            operator,
            compiler.process(element.right)
        ))

        raise exc.StatementError(
            'unknown regexp match operator: {}'.format(operator),
            would_be_sql_string,
            None,
            e
        )

    regex_fn      = getattr(func, func_name)
    regex_fn_call = regex_fn(element.left, element.right)
    return compiler.process(regex_fn_call)