MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / append_column

Method append_column

lib/sqlalchemy/sql/schema.py:1473–1505  ·  view source on GitHub ↗

Append a :class:`_schema.Column` to this :class:`_schema.Table`. The "key" of the newly added :class:`_schema.Column`, i.e. the value of its ``.key`` attribute, will then be available in the ``.c`` collection of this :class:`_schema.Table`, and the column definition

(
        self, column: ColumnClause[Any], *, replace_existing: bool = False
    )

Source from the content-addressed store, hash-verified

1471 )
1472
1473 def append_column(
1474 self, column: ColumnClause[Any], *, replace_existing: bool = False
1475 ) -> None:
1476 """Append a :class:`_schema.Column` to this :class:`_schema.Table`.
1477
1478 The "key" of the newly added :class:`_schema.Column`, i.e. the
1479 value of its ``.key`` attribute, will then be available
1480 in the ``.c`` collection of this :class:`_schema.Table`, and the
1481 column definition will be included in any CREATE TABLE, SELECT,
1482 UPDATE, etc. statements generated from this :class:`_schema.Table`
1483 construct.
1484
1485 Note that this does **not** change the definition of the table
1486 as it exists within any underlying database, assuming that
1487 table has already been created in the database. Relational
1488 databases support the addition of columns to existing tables
1489 using the SQL ALTER command, which would need to be
1490 emitted for an already-existing table that doesn't contain
1491 the newly added column.
1492
1493 :param replace_existing: When ``True``, allows replacing existing
1494 columns. When ``False``, the default, an warning will be raised
1495 if a column with the same ``.key`` already exists. A future
1496 version of sqlalchemy will instead rise a warning.
1497
1498 .. versionadded:: 1.4.0
1499
1500 .. seealso::
1501
1502 :meth:`.Table.insert_column`
1503
1504 """
1505 self._insert_col_impl(column, replace_existing=replace_existing)
1506
1507 def append_constraint(self, constraint: Union[Index, Constraint]) -> None:
1508 """Append a :class:`_schema.Constraint` to this

Calls 1

_insert_col_implMethod · 0.95