def render_query(query, reindent=True):
    """Generate an SQL expression string with bound parameters rendered inline
    for the given SQLAlchemy statement.
    """
    compiled = query.statement.compile(dialect=query.session.get_bind().
        dialect, compile_kwargs={'literal_binds': True})
    raw_sql = str(compiled)
    try:
        import sqlparse
        return sqlparse.format(raw_sql, reindent=reindent)
    except ImportError:
        return raw_sql
