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(
| 3153 | |
| 3154 | |
| 3155 | class TableClause( |
| 3156 | roles.DMLTableRole, Immutable, NamedFromClause[_ColClauseCC_co] |
| 3157 | ): |
| 3158 | """Represents a minimal "table" construct. |
| 3159 | |
| 3160 | This is a lightweight table object that has only a name, a |
| 3161 | collection of columns, which are typically produced |
| 3162 | by the :func:`_expression.column` function, and a schema:: |
| 3163 | |
| 3164 | from sqlalchemy import table, column |
| 3165 | |
| 3166 | user = table( |
| 3167 | "user", |
| 3168 | column("id"), |
| 3169 | column("name"), |
| 3170 | column("description"), |
| 3171 | ) |
| 3172 | |
| 3173 | The :class:`_expression.TableClause` construct serves as the base for |
| 3174 | the more commonly used :class:`_schema.Table` object, providing |
| 3175 | the usual set of :class:`_expression.FromClause` services including |
| 3176 | the ``.c.`` collection and statement generation methods. |
| 3177 | |
| 3178 | It does **not** provide all the additional schema-level services |
| 3179 | of :class:`_schema.Table`, including constraints, references to other |
| 3180 | tables, or support for :class:`_schema.MetaData`-level services. |
| 3181 | It's useful |
| 3182 | on its own as an ad-hoc construct used to generate quick SQL |
| 3183 | statements when a more fully fledged :class:`_schema.Table` |
| 3184 | is not on hand. |
| 3185 | |
| 3186 | """ |
| 3187 | |
| 3188 | __visit_name__ = "table" |
| 3189 | |
| 3190 | _traverse_internals: _TraverseInternalsType = [ |
| 3191 | ( |
| 3192 | "columns", |
| 3193 | InternalTraversal.dp_fromclause_canonical_column_collection, |
| 3194 | ), |
| 3195 | ("name", InternalTraversal.dp_string), |
| 3196 | ("schema", InternalTraversal.dp_string), |
| 3197 | ] |
| 3198 | |
| 3199 | _is_table = True |
| 3200 | |
| 3201 | fullname: str |
| 3202 | |
| 3203 | implicit_returning = False |
| 3204 | """:class:`_expression.TableClause` |
| 3205 | doesn't support having a primary key or column |
| 3206 | -level defaults, so implicit returning doesn't apply.""" |
| 3207 | |
| 3208 | _columns: DedupeColumnCollection[ColumnClause[Any]] |
| 3209 | |
| 3210 | @util.ro_memoized_property |
| 3211 | def _autoincrement_column(self) -> Optional[ColumnClause[Any]]: |
| 3212 | """No PK or default support so no autoincrement column.""" |