Module « sqlalchemy »
Classe « Unicode »
Informations générales
Héritage
builtins.object
Traversible
TypeEngine
builtins.object
Concatenable
String
Unicode
Définition
class Unicode(String):
Description [extrait de Unicode.__doc__]
A variable length Unicode string type.
The :class:`.Unicode` type is a :class:`.String` subclass that assumes
input and output strings that may contain non-ASCII characters, and for
some backends implies an underlying column type that is explicitly
supporting of non-ASCII data, such as ``NVARCHAR`` on Oracle and SQL
Server. This will impact the output of ``CREATE TABLE`` statements and
``CAST`` functions at the dialect level, and also in some cases will
indicate different behavior in the DBAPI itself in how it handles bound
parameters.
The character encoding used by the :class:`.Unicode` type that is used to
transmit and receive data to the database is usually determined by the
DBAPI itself. All modern DBAPIs accommodate non-ASCII strings but may have
different methods of managing database encodings; if necessary, this
encoding should be configured as detailed in the notes for the target DBAPI
in the :ref:`dialect_toplevel` section.
In modern SQLAlchemy, use of the :class:`.Unicode` datatype does not
typically imply any encoding/decoding behavior within SQLAlchemy itself.
Historically, when DBAPIs did not support Python ``unicode`` objects under
Python 2, SQLAlchemy handled unicode encoding/decoding services itself
which would be controlled by the flag :paramref:`.String.convert_unicode`;
this flag is deprecated as it is no longer needed for Python 3.
When using Python 2, data that is passed to columns that use the
:class:`.Unicode` datatype must be of type ``unicode``, and not ``str``
which in Python 2 is equivalent to ``bytes``. In Python 3, all data
passed to columns that use the :class:`.Unicode` datatype should be
of type ``str``. See the flag :paramref:`.String.convert_unicode` for
more discussion of unicode encode/decode behavior under Python 2.
.. warning:: Some database backends, particularly SQL Server with pyodbc,
are known to have undesirable behaviors regarding data that is noted
as being of ``NVARCHAR`` type as opposed to ``VARCHAR``, including
datatype mismatch errors and non-use of indexes. See the section
on :meth:`.DialectEvents.do_setinputsizes` for background on working
around unicode character issues for backends like SQL Server with
pyodbc as well as cx_Oracle.
.. seealso::
:class:`.UnicodeText` - unlengthed textual counterpart
to :class:`.Unicode`.
:paramref:`.String.convert_unicode`
:meth:`.DialectEvents.do_setinputsizes`
Constructeur(s)
Liste des attributs statiques
hashable | True |
RETURNS_BYTES | symbol('RETURNS_BYTES') |
RETURNS_CONDITIONAL | symbol('RETURNS_CONDITIONAL') |
RETURNS_UNICODE | symbol('RETURNS_UNICODE') |
RETURNS_UNKNOWN | symbol('RETURNS_UNKNOWN') |
should_evaluate_none | False |
sort_key_function | None |
Liste des opérateurs
Opérateurs hérités de la classe object
__eq__,
__ge__,
__gt__,
__le__,
__lt__,
__ne__
Liste des méthodes
Toutes les méthodes
Méthodes d'instance
Méthodes statiques
Méthodes dépréciées
Méthodes héritées de la classe String
__init_subclass__, __subclasshook__, bind_processor, get_dbapi_type, literal_processor, result_processor
Méthodes héritées de la classe TypeEngine
__repr__, __str__, adapt, as_generic, bind_expression, coerce_compared_value, column_expression, Comparator, comparator_factory, compare_against_backend, compare_values, compile, copy, copy_value, dialect_impl, evaluates_none, with_variant
Méthodes héritées de la classe Traversible
__class_getitem__, get_children
Méthodes héritées de la classe object
__delattr__,
__dir__,
__format__,
__getattribute__,
__hash__,
__reduce__,
__reduce_ex__,
__setattr__,
__sizeof__
Améliorations / Corrections
Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.
Emplacement :
Description des améliorations :