Skip to content

Table Schema

synapseclient.table.Schema

Bases: SchemaBase

A Schema is an Entity that defines a set of columns in a table.

ATTRIBUTE DESCRIPTION
name

The name for the Table Schema object

description

User readable description of the schema

columns

A list of Column objects or their IDs

parent

The project in Synapse to which this table belongs

properties

A map of Synapse properties

annotations

A map of user defined annotations

local_state

Internal use only

Example:

cols = [Column(name='Isotope', columnType='STRING'),
        Column(name='Atomic Mass', columnType='INTEGER'),
        Column(name='Halflife', columnType='DOUBLE'),
        Column(name='Discovered', columnType='DATE')]

schema = syn.store(Schema(name='MyTable', columns=cols, parent=project))
Source code in synapseclient/table.py
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
class Schema(SchemaBase):
    """
    A Schema is an [Entity][synapseclient.entity.Entity] that defines a set of columns in a table.

    Attributes:
        name:        The name for the Table Schema object
        description: User readable description of the schema
        columns:     A list of [Column][synapseclient.table.Column] objects or their IDs
        parent:      The project in Synapse to which this table belongs
        properties:  A map of Synapse properties
        annotations: A map of user defined annotations
        local_state: Internal use only

    Example:

        cols = [Column(name='Isotope', columnType='STRING'),
                Column(name='Atomic Mass', columnType='INTEGER'),
                Column(name='Halflife', columnType='DOUBLE'),
                Column(name='Discovered', columnType='DATE')]

        schema = syn.store(Schema(name='MyTable', columns=cols, parent=project))
    """

    _synapse_entity_type = "org.sagebionetworks.repo.model.table.TableEntity"

    def __init__(
        self,
        name=None,
        columns=None,
        parent=None,
        properties=None,
        annotations=None,
        local_state=None,
        **kwargs,
    ):
        super(Schema, self).__init__(
            name=name,
            columns=columns,
            properties=properties,
            annotations=annotations,
            local_state=local_state,
            parent=parent,
            **kwargs,
        )