MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / quoted_name

Class quoted_name

lib/sqlalchemy/sql/elements.py:5681–5775  ·  lib/sqlalchemy/sql/elements.py::quoted_name

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 behavi

Source from the content-addressed store, hash-verified

5679
5680
5681class quoted_name(util.MemoizedSlots, str):
5682 class="st">"""Represent a SQL identifier combined with quoting preferences.
5683
5684 :class:`.quoted_name` is a Python unicode/str subclass which
5685 represents a particular identifier name along with a
5686 ``quote`` flag. This ``quote`` flag, when set to
5687 ``True`` or ``False``, overrides automatic quoting behavior
5688 for this identifier in order to either unconditionally quote
5689 or to not quote the name. If left at its default of ``None``,
5690 quoting behavior is applied to the identifier on a per-backend basis
5691 based on an examination of the token itself.
5692
5693 A :class:`.quoted_name` object with ``quote=True`` is also
5694 prevented from being modified in the case of a so-called
5695 class="st">"name normalize" option. Certain database backends, such as
5696 Oracle Database, Firebird, and DB2 class="st">"normalize" case-insensitive names
5697 as uppercase. The SQLAlchemy dialects for these backends
5698 convert from SQLAlchemy&class="cm">#x27;s lower-case-means-insensitive convention
5699 to the upper-case-means-insensitive conventions of those backends.
5700 The ``quote=True`` flag here will prevent this conversion from occurring
5701 to support an identifier that&class="cm">#x27;s quoted as all lower case against
5702 such a backend.
5703
5704 The :class:`.quoted_name` object is normally created automatically
5705 when specifying the name for key schema constructs such as
5706 :class:`_schema.Table`, :class:`_schema.Column`, and others.
5707 The class can also be
5708 passed explicitly as the name to any function that receives a name which
5709 can be quoted, such as :meth:`.Inspector.has_table` with an
5710 unconditionally quoted name::
5711
5712 from sqlalchemy import create_engine
5713 from sqlalchemy import inspect
5714 from sqlalchemy.sql import quoted_name
5715
5716 engine = create_engine(class="st">"oracle+oracledb://some_dsn")
5717 print(inspect(engine).has_table(quoted_name(class="st">"some_table", True)))
5718
5719 The above logic will run the class="st">"has table" logic against the Oracle Database
5720 backend, passing the name exactly as ``class="st">"some_table"`` without converting to
5721 upper case.
5722
5723 A :class:`.quoted_name` object with ``quote=False`` may be passed to APIs
5724 that apply automatic quoting in order to keep the given name unquoted,
5725 such as when a PostgreSQL ``INHERITS`` option refers to a schema-qualified
5726 table name like ``my_schema.some_table``.
5727
5728 class="st">"""
5729
5730 __slots__ = class="st">"quote", class="st">"lower", class="st">"upper"
5731
5732 quote: Optional[bool]
5733
5734 @overload
5735 @classmethod
5736 def construct(cls, value: str, quote: Optional[bool]) -> quoted_name: ...
5737
5738 @overload

Calls

no outgoing calls