Exemple #1
0
def compile(expr):
    """
    Force compilation of expression for the PostgreSQL target
    """
    from .client import PostgreSQLDialect
    from ibis.sql.alchemy import to_sqlalchemy
    return to_sqlalchemy(expr, dialect=PostgreSQLDialect)
Exemple #2
0
def compile(expr):
    """
    Force compilation of expression for the PostgreSQL target
    """
    from .client import PostgreSQLDialect
    from ibis.sql.alchemy import to_sqlalchemy
    return to_sqlalchemy(expr, dialect=PostgreSQLDialect)
Exemple #3
0
def compile(expr, params=None):
    """
    Force compilation of expression for the SQLite target
    """
    from ibis.sql.alchemy import to_sqlalchemy

    return to_sqlalchemy(expr, dialect.make_context(params=params))
Exemple #4
0
def compile(expr, params=None):
    """
    Force compilation of expression for the SQLite target
    """
    from ibis.sql.alchemy import to_sqlalchemy

    return to_sqlalchemy(expr, dialect.make_context(params=params))
Exemple #5
0
def compile(expr):
    """Compile an ibis expression to the PostgreSQL target.

    Parameters
    ----------
    expr : ibis.expr.types.Expr
        The ibis expression to compile

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

    Examples
    --------
    >>> import os
    >>> database = os.environ.get('IBIS_TEST_POSTGRES_DB', 'ibis_testing')
    >>> con = connect(database=database, host='localhost')
    >>> 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=PostgreSQLDialect)
def compile(expr, params=None):
    """Compile an ibis expression to the Snowflake 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
    >>> user = os.environ.get('IBIS_TEST_SNOWFLAKE_USER', getpass.getuser())
    >>> password = os.environ.get('IBIS_TEST_SNOWFLAKE_PASSWORD')
    >>> account = os.environ.get('IBIS_TEST_SNOWFLAKE_ACCOUNT')
    >>> database = os.environ.get('IBIS_TEST_SNOWFLAKE_DATABASE',
    ...                           'ibis_testing')
    >>> con = connect(
    ...     database=database,
    ...     account=account,
    ...     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))
Exemple #7
0
def compile(expr, params=None):
    """Compile an ibis expression to the PostgreSQL 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_POSTGRES_HOST', 'localhost')
    >>> user = os.environ.get('IBIS_TEST_POSTGRES_USER', getpass.getuser())
    >>> password = os.environ.get('IBIS_TEST_POSTGRES_PASSWORD')
    >>> database = os.environ.get('IBIS_TEST_POSTGRES_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))
Exemple #8
0
def compile(expr, params=None):
    """Compile an ibis expression to the MSSQL target.

    Parameters
    ----------
    expr : ibis.expr.types.Expr
        The ibis expression to compile
    params : dict, optional
        ``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_MSSQL_HOST', 'localhost')
    >>> user = os.environ.get('IBIS_TEST_MSSQL_USER', getpass.getuser())
    >>> password = os.environ.get('IBIS_TEST_MSSQL_PASSWORD')
    >>> database = os.environ.get('IBIS_TEST_MSSQL_DATABASE', 'master')
    >>> 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 + ? AS tmp
    FROM functional_alltypes AS t0
    """
    return to_sqlalchemy(expr, dialect.make_context(params=params))
 def _compare_sqla(self, expr, sqla):
     result = alch.to_sqlalchemy(expr)
     assert str(result.compile()) == str(sqla.compile())
Exemple #10
0
 def _compare_sqla(self, expr, sqla):
     result = alch.to_sqlalchemy(expr)
     assert str(result.compile()) == str(sqla.compile())
Exemple #11
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())
Exemple #12
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())
def compile(expr, params=None):
    return to_sqlalchemy(expr, dialect.make_context(params=params))