Skip to content

Table Types

Manual, Lookup, Imported, Computed, Part

Hosts the table tiers, user tables should be derived from.

TableMeta

Bases: type

TableMeta subclasses allow applying some instance methods and properties directly at class level. For example, this allows Table.to_dicts() instead of Table().to_dicts().

connection property

connection

The database connection for this table.

table_name property

table_name

The table name formatted for MySQL.

full_table_name property

full_table_name

The fully qualified table name (quoted per backend).

UserTable

Bases: Table

A subclass of UserTable is a dedicated class interfacing a base table. UserTable is initialized by the decorator generated by schema().

definition property

definition

:return: a string containing the table definition using the DataJoint DDL.

Manual

Bases: UserTable

Inherit from this class if the table's values are entered manually.

Lookup

Bases: UserTable

Inherit from this class if the table's values are for lookup. This is currently equivalent to defining the table as Manual and serves semantic purposes only.

Imported

Bases: UserTable, AutoPopulate

Inherit from this class if the table's values are imported from external data sources. The inherited class must at least provide the function _make_tuples.

Computed

Bases: UserTable, AutoPopulate

Inherit from this class if the table's values are computed from other tables in the schema. The inherited class must at least provide the function _make_tuples.

PartMeta

Bases: TableMeta

Metaclass for Part tables with overridden class properties.

table_name property

table_name

The table name for a Part is derived from its master table.

full_table_name property

full_table_name

The fully qualified table name (quoted per backend).

master property

master

The master table for this Part table.

Part

Bases: UserTable

Inherit from this class if the table's values are details of an entry in another table and if this table is populated by the other table. For example, the entries inheriting from dj.Part could be single entries of a matrix, while the parent table refers to the entire matrix. Part tables are implemented as classes inside classes.

delete

delete(part_integrity='enforce', **kwargs)

Delete from a Part table.

Args: part_integrity: Policy for master-part integrity. One of: - "enforce" (default): Error - delete from master instead. - "ignore": Allow direct deletion (breaks master-part integrity). - "cascade": Delete parts AND cascade up to delete master. **kwargs: Additional arguments passed to Table.delete() (transaction, prompt)

Raises: DataJointError: If part_integrity="enforce" (direct Part deletes prohibited)

drop

drop(part_integrity='enforce')

Drop a Part table.

Args: part_integrity: Policy for master-part integrity. One of: - "enforce" (default): Error - drop master instead. - "ignore": Allow direct drop (breaks master-part structure). Note: "cascade" is not supported for drop (too destructive).

Raises: DataJointError: If part_integrity="enforce" (direct Part drops prohibited)