Пример #1
0
def compile(expr, params=None):
    """
    Force compilation of expression for the SQLite target
    """
    from ibis.backends.base_sqlalchemy.alchemy import to_sqlalchemy

    return to_sqlalchemy(expr, dialect.make_context(params=params))
Пример #2
0
def compile(expr, params=None):
    """Compile an ibis expression to the MySQL target.

    Parameters
    ----------
    expr : ibis.expr.types.Expr
        The ibis expression to compile
    params : dict or None
        ``dict`` mapping :class:`ibis.expr.types.ScalarParameter` objects to
        values

    Returns
    -------
    sqlalchemy_expression : sqlalchemy.sql.expression.ClauseElement

    Examples
    --------
    >>> import os
    >>> import getpass
    >>> host = os.environ.get('IBIS_TEST_MYSQL_HOST', 'localhost')
    >>> user = os.environ.get('IBIS_TEST_MYSQL_USER', getpass.getuser())
    >>> password = os.environ.get('IBIS_TEST_MYSQL_PASSWORD')
    >>> database = os.environ.get('IBIS_TEST_MYSQL_DATABASE',
    ...                           'ibis_testing')
    >>> con = connect(
    ...     database=database,
    ...     host=host,
    ...     user=user,
    ...     password=password
    ... )
    >>> t = con.table('functional_alltypes')
    >>> expr = t.double_col + 1
    >>> sqla = compile(expr)
    >>> print(str(sqla))  # doctest: +NORMALIZE_WHITESPACE
    SELECT t0.double_col + %(param_1)s AS tmp
    FROM functional_alltypes AS t0
    """
    return to_sqlalchemy(expr, dialect.make_context(params=params))
Пример #3
0
 def _compare_sqla(self, expr, sqla):
     context = alch.AlchemyContext(dialect=alch.AlchemyDialect())
     result = alch.to_sqlalchemy(expr, context)
     assert str(result.compile()) == str(sqla.compile())
Пример #4
0
def compile(expr, params=None):
    """
    Force compilation of expression for the SQLite target
    """
    return to_sqlalchemy(expr, dialect.make_context(params=params))