MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / TableClause

Class TableClause

lib/sqlalchemy/sql/selectable.py:3094–3250  ·  view source on GitHub ↗

Represents a minimal "table" construct. This is a lightweight table object that has only a name, a collection of columns, which are typically produced by the :func:`_expression.column` function, and a schema:: from sqlalchemy import table, column user = table(

Source from the content-addressed store, hash-verified

3092
3093
3094class TableClause(roles.DMLTableRole, Immutable, NamedFromClause):
3095 """Represents a minimal "table" construct.
3096
3097 This is a lightweight table object that has only a name, a
3098 collection of columns, which are typically produced
3099 by the :func:`_expression.column` function, and a schema::
3100
3101 from sqlalchemy import table, column
3102
3103 user = table(
3104 "user",
3105 column("id"),
3106 column("name"),
3107 column("description"),
3108 )
3109
3110 The :class:`_expression.TableClause` construct serves as the base for
3111 the more commonly used :class:`_schema.Table` object, providing
3112 the usual set of :class:`_expression.FromClause` services including
3113 the ``.c.`` collection and statement generation methods.
3114
3115 It does **not** provide all the additional schema-level services
3116 of :class:`_schema.Table`, including constraints, references to other
3117 tables, or support for :class:`_schema.MetaData`-level services.
3118 It's useful
3119 on its own as an ad-hoc construct used to generate quick SQL
3120 statements when a more fully fledged :class:`_schema.Table`
3121 is not on hand.
3122
3123 """
3124
3125 __visit_name__ = "table"
3126
3127 _traverse_internals: _TraverseInternalsType = [
3128 (
3129 "columns",
3130 InternalTraversal.dp_fromclause_canonical_column_collection,
3131 ),
3132 ("name", InternalTraversal.dp_string),
3133 ("schema", InternalTraversal.dp_string),
3134 ]
3135
3136 _is_table = True
3137
3138 fullname: str
3139
3140 implicit_returning = False
3141 """:class:`_expression.TableClause`
3142 doesn't support having a primary key or column
3143 -level defaults, so implicit returning doesn't apply."""
3144
3145 @util.ro_memoized_property
3146 def _autoincrement_column(self) -> Optional[ColumnClause[Any]]:
3147 """No PK or default support so no autoincrement column."""
3148 return None
3149
3150 def __init__(self, name: str, *columns: ColumnClause[Any], **kw: Any):
3151 super().__init__()

Callers 1

tableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected