sqlalchemy :: types :: Unicode :: Class Unicode |
[frames] | no frames]

# Class Unicode

    A variable length Unicode string.

    The ``Unicode`` type is a :class:`String` which converts Python
    ``unicode`` objects (i.e., strings that are defined as
    ``u'somevalue'``) into encoded bytestrings when passing the value
    to the database driver, and similarly decodes values from the
    database back into Python ``unicode`` objects.

    When using the ``Unicode`` type, it is only appropriate to pass
    Python ``unicode`` objects, and not plain ``str``.  If a
    bytestring (``str``) is passed, a runtime warning is issued.  If
    you notice your application raising these warnings but you're not
    sure where, the Python ``warnings`` filter can be used to turn
    these warnings into exceptions which will illustrate a stack
    trace::

      import warnings
      warnings.simplefilter('error')

    Bytestrings sent to and received from the database are encoded
    using the dialect's
    :attr:`~sqlalchemy.engine.base.Dialect.encoding`, which defaults
    to `utf-8`.

    A synonym for String(length, convert_unicode=True, assert_unicode='warn').

Instance Methods
__init__(self, length=None, **kwargs) Create a Unicode-converting String type. |
Inherited from `String`: `adapt`, `bind_processor`, `get_dbapi_type`, `result_processor` Inherited from `Concatenable`: `adapt_operator` Inherited from `TypeEngine`: `__getstate__`, `dialect_impl`, `get_col_spec`, `get_search_list` Inherited from `AbstractType`: `__repr__`, `compare_values`, `copy_value`, `is_mutable` Inherited from `object`: `__delattr__`, `__format__`, `__getattribute__`, `__hash__`, `__new__`, `__reduce__`, `__reduce_ex__`, `__setattr__`, `__sizeof__`, `__str__`, `__subclasshook__`

Properties
Inherited from `object`: `__class__`

Method Details

### __init__(self, length=None, **kwargs) (Constructor) |
Create a Unicode-converting String type. Parameters: `length` - optional, a length for the column for use in DDL statements. May be safely omitted if no `CREATE TABLE` will be issued. Certain databases may require a length for use in DDL, and will raise an exception when the `CREATE TABLE` DDL is issued. Whether the value is interpreted as bytes or characters is database specific. Overrides: object.__init__