class quoted_name(util.MemoizedSlots, str): (source)
Known subclasses: sqlalchemy.sql.elements._truncated_label
Represent a SQL identifier combined with quoting preferences. :class:`.quoted_name` is a Python unicode/str subclass which represents a particular identifier name along with a ``quote`` flag. This ``quote`` flag, when set to ``True`` or ``False``, overrides automatic quoting behavior for this identifier in order to either unconditionally quote or to not quote the name. If left at its default of ``None``, quoting behavior is applied to the identifier on a per-backend basis based on an examination of the token itself. A :class:`.quoted_name` object with ``quote=True`` is also prevented from being modified in the case of a so-called "name normalize" option. Certain database backends, such as Oracle, Firebird, and DB2 "normalize" case-insensitive names as uppercase. The SQLAlchemy dialects for these backends convert from SQLAlchemy's lower-case-means-insensitive convention to the upper-case-means-insensitive conventions of those backends. The ``quote=True`` flag here will prevent this conversion from occurring to support an identifier that's quoted as all lower case against such a backend. The :class:`.quoted_name` object is normally created automatically when specifying the name for key schema constructs such as :class:`_schema.Table`, :class:`_schema.Column`, and others. The class can also be passed explicitly as the name to any function that receives a name which can be quoted. Such as to use the :meth:`_engine.Engine.has_table` method with an unconditionally quoted name:: from sqlalchemy import create_engine from sqlalchemy import inspect from sqlalchemy.sql import quoted_name engine = create_engine("oracle+cx_oracle://some_dsn") print(inspect(engine).has_table(quoted_name("some_table", True))) The above logic will run the "has table" logic against the Oracle backend, passing the name exactly as ``"some_table"`` without converting to upper case. .. versionadded:: 0.9.0 .. versionchanged:: 1.2 The :class:`.quoted_name` construct is now importable from ``sqlalchemy.sql``, in addition to the previous location of ``sqlalchemy.sql.elements``.
Class Method | construct |
Undocumented |
Method | __new__ |
Undocumented |
Method | __reduce__ |
Undocumented |
Class Variable | __slots__ |
Undocumented |
Instance Variable | quote |
Undocumented |
Method | _memoized |
Undocumented |
Method | _memoized |
Undocumented |
Inherited from MemoizedSlots
:
Method | __getattr__ |
Undocumented |
Method | _fallback |
Undocumented |