MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / CreateTable

Class CreateTable

lib/sqlalchemy/sql/ddl.py:541–575  ·  view source on GitHub ↗

Represent a CREATE TABLE statement.

Source from the content-addressed store, hash-verified

539
540
541class CreateTable(TableCreateDDL):
542 """Represent a CREATE TABLE statement."""
543
544 __visit_name__ = "create_table"
545
546 def __init__(
547 self,
548 element: Table,
549 include_foreign_key_constraints: Optional[
550 typing_Sequence[ForeignKeyConstraint]
551 ] = None,
552 if_not_exists: bool = False,
553 ) -> None:
554 """Create a :class:`.CreateTable` construct.
555
556 :param element: a :class:`_schema.Table` that's the subject
557 of the CREATE
558 :param on: See the description for 'on' in :class:`.DDL`.
559 :param include_foreign_key_constraints: optional sequence of
560 :class:`_schema.ForeignKeyConstraint` objects that will be included
561 inline within the CREATE construct; if omitted, all foreign key
562 constraints that do not specify use_alter=True are included.
563
564 :param if_not_exists: if True, an IF NOT EXISTS operator will be
565 applied to the construct.
566
567 .. versionadded:: 1.4.0b2
568
569 """
570 super().__init__(element, if_not_exists=if_not_exists)
571 self.columns = [CreateColumn(column) for column in element.columns]
572 self.include_foreign_key_constraints = include_foreign_key_constraints
573
574 def to_metadata(self, metadata: MetaData, table: Table) -> Self:
575 return self.__class__(table, if_not_exists=self.if_not_exists)
576
577
578class _TableViaSelect(TableCreateDDL, ExecutableDDLElement):

Callers 15

visit_tableMethod · 0.85
test_create_ddlMethod · 0.85
test_other_optionsMethod · 0.85
test_nullable_kwargMethod · 0.85
test_stringMethod · 0.85
test_string_w_quotesMethod · 0.85
test_textMethod · 0.85
test_text_w_quotesMethod · 0.85

Calls

no outgoing calls

Tested by 15

test_create_ddlMethod · 0.68
test_other_optionsMethod · 0.68
test_nullable_kwargMethod · 0.68
test_stringMethod · 0.68
test_string_w_quotesMethod · 0.68
test_textMethod · 0.68
test_text_w_quotesMethod · 0.68