'Construct a new :class:`.TextClause` clause, representing
a textual SQL string directly.
E.g.::
fom sqlalchemy import text
t = text("SELECT * FROM users")
result = connection.execute(t)
The advantages :func:`.text` provides over a plain string are
backend-neutral support for bind parameters, per-statement
execution options, as well as
bind parameter and result-column typing behavior, allowing
SQLAlchemy type constructs to play a role when executing
a statement that is specified literally.  The construct can also
be provided with a ``.c`` collection of column elements, allowing
it to be embedded in other SQL expression constructs as a subquery.
Bind parameters are specified by name, using the format ``:name``.
E.g.::
t = text("SELECT * FROM users WHERE id=:user_id")
result = connection.execute(t, user_id=12)
For SQL statements where a colon is required verbatim, as within
an inline string, use a backslash to escape::
t = text("SELECT * FROM users WHERE name=\'\:username\'")
The :class:`.TextClause` construct includes methods which can
provide information about the bound parameters as well as the column
values which would be returned from the textual statement, assuming
it\'s an executable SELECT type of statement.  The :meth:`.TextClause.bindparams`
method is used to provide bound parameter detail, and
:meth:`.TextClause.columns` method allows specification of
return columns including names and types::
t = text("SELECT * FROM users WHERE id=:user_id").\
bindparams(user_id=7).\
columns(id=Integer, name=String)
for id, name in connection.execute(t):
print(id, name)
The :func:`.text` construct is used internally in cases when
a literal string is specified for part of a larger query, such as
when a string is specified to the :meth:`.Select.where` method of
:class:`.Select`.  In those cases, the same
bind parameter syntax is applied::
s = select([users.c.id, users.c.name]).where("id=:user_id")
result = connection.execute(s, user_id=12)
Using :func:`.text` explicitly usually implies the construction
of a full, standalone statement.   As such, SQLAlchemy refers
to it as an :class:`.Executable` object, and it supports
the :meth:`Executable.execution_options` method.  For example,
a :func:`.text` construct that should be subject to "autocommit"
can be set explicitly so using the :paramref:`.Connection.execution_options.autocommit`
option::
t = text("EXEC my_procedural_thing()").\
execution_options(autocommit=True)
Note that SQLAlchemy\'s usual "autocommit" behavior applies to
:func:`.text` constructs implicitly - that is, statements which begin
with a phrase such as ``INSERT``, ``UPDATE``, ``DELETE``,
or a variety of other phrases specific to certain backends, will
be eligible for autocommit if no transaction is in progress.
:param text:
the text of the SQL statement to be created.  use ``:<param>``
to specify bind parameters; they will be compiled to their
engine-specific format.
:param autocommit:
Deprecated.  Use .execution_options(autocommit=<True|False>)
to set the autocommit option.
:param bind:
an optional connection or engine to be used for this text query.
:param bindparams:
Deprecated.  A list of :func:`.bindparam` instances used to
provide information about parameters embedded in the statement.
This argument now invokes the :meth:`.TextClause.bindparams`
method on the construct before returning it.  E.g.::
stmt = text("SELECT * FROM table WHERE id=:id",
bindparams=[bindparam(\'id\', value=5, type_=Integer)])
Is equivalent to::
stmt = text("SELECT * FROM table WHERE id=:id").\
bindparams(bindparam(\'id\', value=5, type_=Integer))
.. deprecated:: 0.9.0 the :meth:`.TextClause.bindparams` method
supersedes the ``bindparams`` argument to :func:`.text`.
:param typemap:
Deprecated.  A dictionary mapping the names of columns
represented in the columns clause of a ``SELECT`` statement
to type objects,
which will be used to perform post-processing on columns within
the result set.  This parameter now invokes the :meth:`.TextClause.columns`
method, which returns a :class:`.TextAsFrom` construct that gains
a ``.c`` collection and can be embedded in other expressions.  E.g.::
stmt = text("SELECT * FROM table",
typemap={\'id\': Integer, \'name\': String},
Is equivalent to::
stmt = text("SELECT * FROM table").columns(id=Integer, name=String)
Or alternatively::
from sqlalchemy.sql import column
stmt = text("SELECT * FROM table").columns(
column(\'id\', Integer),
column(\'name\', String)
.. deprecated:: 0.9.0 the :meth:`.TextClause.columns` method
supersedes the ``typemap`` argument to :func:`.text`.'

@classmethod
def _create_text(self, text, bind=None, bindparams=None, typemap=None, autocommit=None):

    stmt = TextClause(text, bind=bind)
    if bindparams:
        stmt = stmt.bindparams(*bindparams)
    if typemap:
        stmt = stmt.columns(**typemap)
    if (autocommit is not None):
        util.warn_deprecated(u'autocommit    on    text()    is    deprecated.        Use    .execution_options(autocommit=True)')
        stmt = stmt.execution_options(autocommit=autocommit)
    return stmt
