class_docstr: PostgreSQL ENUM type.
  
  This is a subclass of :class:`_types.Enum` which includes
  support for PG's ``CREATE TYPE`` and ``DROP TYPE``.
  
  When the builtin type :class:`_types.Enum` is used and the
  :paramref:`.Enum.native_enum` flag is left at its default of
  True, the PostgreSQL backend will use a :class:`_postgresql.ENUM`
  type as the implementation, so the special create/drop rules
  will be used.
  
  The create/drop behavior of ENUM is necessarily intricate, due to the
  awkward relationship the ENUM type has in relationship to the
  parent table, in that it may be "owned" by just a single table, or
  may be shared among many tables.
  
  When using :class:`_types.Enum` or :class:`_postgresql.ENUM`
  in an "inline" fashion, the ``CREATE TYPE`` and ``DROP TYPE`` is emitted
  corresponding to when the :meth:`_schema.Table.create` and
  :meth:`_schema.Table.drop`
  methods are called::
  
      table = Table('sometable', metadata,
          Column('some_enum', ENUM('a', 'b', 'c', name='myenum'))
      )
  
      table.create(engine)  # will emit CREATE ENUM and CREATE TABLE
      table.drop(engine)  # will emit DROP TABLE and DROP ENUM
  
  To use a common enumerated type between multiple tables, the best
  practice is to declare the :class:`_types.Enum` or
  :class:`_postgresql.ENUM` independently, and associate it with the
  :class:`_schema.MetaData` object itself::
  
      my_enum = ENUM('a', 'b', 'c', name='myenum', metadata=metadata)
  
      t1 = Table('sometable_one', metadata,
          Column('some_enum', myenum)
      )
  
      t2 = Table('sometable_two', metadata,
          Column('some_enum', myenum)
      )
  
  When this pattern is used, care must still be taken at the level
  of individual table creates.  Emitting CREATE TABLE without also
  specifying ``checkfirst=True`` will still cause issues::
  
      t1.create(engine) # will fail: no such type 'myenum'
  
  If we specify ``checkfirst=True``, the individual table-level create
  operation will check for the ``ENUM`` and create if not exists::
  
      # will check if enum exists, and emit CREATE TYPE if not
      t1.create(engine, checkfirst=True)
  
  When using a metadata-level ENUM type, the type will always be created
  and dropped if either the metadata-wide create/drop is called::
  
      metadata.create_all(engine)  # will emit CREATE TYPE
      metadata.drop_all(engine)  # will emit DROP TYPE
  
  The type can also be created and dropped directly::
  
      my_enum.create(engine)
      my_enum.drop(engine)
class_docstr_tok: ["PostgreSQL","ENUM","type",".","This","is","a","subclass","of",":","class",":","`","_types.Enum","`","which","includes","support","for","PG","'s","``","CREATE","TYPE","``","and","``","DROP","TYPE","``",".","When","the","builtin","type",":","class",":","`","_types.Enum","`","is","used","and","the",":","paramref",":","`",".Enum.native_enum","`","flag","is","left","at","its","default","of","True",",","the","PostgreSQL","backend","will","use","a",":","class",":","`","_postgresql.ENUM","`","type","as","the","implementation",",","so","the","special","create\/drop","rules","will","be","used",".","The","create\/drop","behavior","of","ENUM","is","necessarily","intricate",",","due","to","the","awkward","relationship","the","ENUM","type","has","in","relationship","to","the","parent","table",",","in","that","it","may","be","``","owned","''","by","just","a","single","table",",","or","may","be","shared","among","many","tables",".","When","using",":","class",":","`","_types.Enum","`","or",":","class",":","`","_postgresql.ENUM","`","in","an","``","inline","''","fashion",",","the","``","CREATE","TYPE","``","and","``","DROP","TYPE","``","is","emitted","corresponding","to","when","the",":","meth",":","`","_schema.Table.create","`","and",":","meth",":","`","_schema.Table.drop","`","methods","are","called",":",":","table","=","Table","(","'sometable","'",",","metadata",",","Column","(","'some_enum","'",",","ENUM","(","'","a","'",",","'","b","'",",","'","c","'",",","name='myenum","'",")",")",")","table.create","(","engine",")","#","will","emit","CREATE","ENUM","and","CREATE","TABLE","table.drop","(","engine",")","#","will","emit","DROP","TABLE","and","DROP","ENUM","To","use","a","common","enumerated","type","between","multiple","tables",",","the","best","practice","is","to","declare","the",":","class",":","`","_types.Enum","`","or",":","class",":","`","_postgresql.ENUM","`","independently",",","and","associate","it","with","the",":","class",":","`","_schema.MetaData","`","object","itself",":",":","my_enum","=","ENUM","(","'","a","'",",","'","b","'",",","'","c","'",",","name='myenum","'",",","metadata=metadata",")","t1","=","Table","(","'sometable_one","'",",","metadata",",","Column","(","'some_enum","'",",","myenum",")",")","t2","=","Table","(","'sometable_two","'",",","metadata",",","Column","(","'some_enum","'",",","myenum",")",")","When","this","pattern","is","used",",","care","must","still","be","taken","at","the","level","of","individual","table","creates",".","Emitting","CREATE","TABLE","without","also","specifying","``","checkfirst=True","``","will","still","cause","issues",":",":","t1.create","(","engine",")","#","will","fail",":","no","such","type","'myenum'","If","we","specify","``","checkfirst=True","``",",","the","individual","table-level","create","operation","will","check","for","the","``","ENUM","``","and","create","if","not","exists",":",":","#","will","check","if","enum","exists",",","and","emit","CREATE","TYPE","if","not","t1.create","(","engine",",","checkfirst=True",")","When","using","a","metadata-level","ENUM","type",",","the","type","will","always","be","created","and","dropped","if","either","the","metadata-wide","create\/drop","is","called",":",":","metadata.create_all","(","engine",")","#","will","emit","CREATE","TYPE","metadata.drop_all","(","engine",")","#","will","emit","DROP","TYPE","The","type","can","also","be","created","and","dropped","directly",":",":","my_enum.create","(","engine",")","my_enum.drop","(","engine",")"]
docstr: Construct an :class:`_postgresql.ENUM`.
  
  Arguments are the same as that of
  :class:`_types.Enum`, but also including
  the following parameters.
  
  :param create_type: Defaults to True.
   Indicates that ``CREATE TYPE`` should be
   emitted, after optionally checking for the
   presence of the type, when the parent
   table is being created; and additionally
   that ``DROP TYPE`` is called when the table
   is dropped.    When ``False``, no check
   will be performed and no ``CREATE TYPE``
   or ``DROP TYPE`` is emitted, unless
   :meth:`~.postgresql.ENUM.create`
   or :meth:`~.postgresql.ENUM.drop`
   are called directly.
   Setting to ``False`` is helpful
   when invoking a creation scheme to a SQL file
   without access to the actual database -
   the :meth:`~.postgresql.ENUM.create` and
   :meth:`~.postgresql.ENUM.drop` methods can
   be used to emit SQL to a target bind.
docstr_tok: ["Construct","an",":","class",":","`","_postgresql.ENUM","`",".","Arguments","are","the","same","as","that","of",":","class",":","`","_types.Enum","`",",","but","also","including","the","following","parameters",".",":","param","create_type",":","Defaults","to","True",".","Indicates","that","``","CREATE","TYPE","``","should","be","emitted",",","after","optionally","checking","for","the","presence","of","the","type",",","when","the","parent","table","is","being","created",";","and","additionally","that","``","DROP","TYPE","``","is","called","when","the","table","is","dropped",".","When","``","False","``",",","no","check","will","be","performed","and","no","``","CREATE","TYPE","``","or","``","DROP","TYPE","``","is","emitted",",","unless",":","meth",":","`","~.postgresql.ENUM.create","`","or",":","meth",":","`","~.postgresql.ENUM.drop","`","are","called","directly",".","Setting","to","``","False","``","is","helpful","when","invoking","a","creation","scheme","to","a","SQL","file","without","access","to","the","actual","database","-","the",":","meth",":","`","~.postgresql.ENUM.create","`","and",":","meth",":","`","~.postgresql.ENUM.drop","`","methods","can","be","used","to","emit","SQL","to","a","target","bind","."]
code: def __init__(
      self,
      *enums,
      name: Union[str, _NoArg, None] = _NoArg.NO_ARG,
      create_type: bool = True,
      **kw,
  ):
      """Construct an :class:`_postgresql.ENUM`.
  
      Arguments are the same as that of
      :class:`_types.Enum`, but also including
      the following parameters.
  
      :param create_type: Defaults to True.
       Indicates that ``CREATE TYPE`` should be
       emitted, after optionally checking for the
       presence of the type, when the parent
       table is being created; and additionally
       that ``DROP TYPE`` is called when the table
       is dropped.    When ``False``, no check
       will be performed and no ``CREATE TYPE``
       or ``DROP TYPE`` is emitted, unless
       :meth:`~.postgresql.ENUM.create`
       or :meth:`~.postgresql.ENUM.drop`
       are called directly.
       Setting to ``False`` is helpful
       when invoking a creation scheme to a SQL file
       without access to the actual database -
       the :meth:`~.postgresql.ENUM.create` and
       :meth:`~.postgresql.ENUM.drop` methods can
       be used to emit SQL to a target bind.
  
      """
      native_enum = kw.pop("native_enum", None)
      if native_enum is False:
          util.warn(
              "the native_enum flag does not apply to the "
              "sqlalchemy.dialects.postgresql.ENUM datatype; this type "
              "always refers to ENUM.   Use sqlalchemy.types.Enum for "
              "non-native enum."
          )
      self.create_type = create_type
      if name is not _NoArg.NO_ARG:
          kw["name"] = name
      super().__init__(*enums, **kw)
  
imports: from __future__ import annotations
  from typing import Any
  from typing import Optional
  from typing import Type
  from typing import TYPE_CHECKING
  from typing import Union
  from ...None import schema
  from ...None import util
  from ...sql import coercions
  from ...sql import elements
  from ...sql import roles
  from ...sql import sqltypes
  from ...sql import type_api
  from ...sql.base import _NoArg
  from ...sql.ddl import InvokeCreateDDLBase
  from ...sql.ddl import InvokeDropDDLBase
label_desc: Use image node_id 1 to create a new ENUM object from inherited base classes: NamedType, type_api, sqltypes with example: obj = ENUM()