Logo Search packages:      
Sourcecode: sqlalchemy version File versions  Download package

def sqlalchemy::schema::Column::__init__ (   self,
  name,
  type,
  args,
  kwargs 
)

constructs a new Column object.  Arguments are:

name : the name of this column.  this should be the identical name as it appears,
or will appear, in the database.

type: the TypeEngine for this column.
This can be any subclass of types.AbstractType, including the database-agnostic types defined 
in the types module, database-specific types defined within specific database modules, or user-defined types.

*args: Constraint, ForeignKey, ColumnDefault and Sequence objects should be added as list values.

**kwargs : keyword arguments include:

key=None : an optional "alias name" for this column.  The column will then be identified everywhere
in an application, including the column list on its Table, by this key, and not the given name.  
Generated SQL, however, will still reference the column by its actual name.

primary_key=False : True if this column is a primary key column.  Multiple columns can have this flag
set to specify composite primary keys.  As an alternative, the primary key of a Table can be specified
via an explicit PrimaryKeyConstraint instance appended to the Table's list of objects.

nullable=True : True if this column should allow nulls. Defaults to True unless this column is a primary
key column.

default=None : a scalar, python callable, or ClauseElement representing the "default value" for this column,
which will be invoked upon insert if this column is not present in the insert list or is given a value
of None.  The default expression will be converted into a ColumnDefault object upon initialization.

_is_oid=False : used internally to indicate that this column is used as the quasi-hidden "oid" column

index=False : Indicates that this column is
indexed. The name of the index is autogenerated.
to specify indexes with explicit names or indexes that contain multiple 
columns, use the Index construct instead.

unique=False : Indicates that this column 
contains a unique constraint, or if index=True as well, indicates
that the Index should be created with the unique flag.
To specify multiple columns in the constraint/index or to specify an 
explicit name, use the UniqueConstraint or Index constructs instead.

autoincrement=True : Indicates that integer-based primary key columns should have autoincrementing behavior,
if supported by the underlying database.  This will affect CREATE TABLE statements such that they will
use the databases "auto-incrementing" keyword (such as SERIAL for postgres, AUTO_INCREMENT for mysql) and will
also affect the behavior of some dialects during INSERT statement execution such that they will assume primary 
key values are created in this manner.  If a Column has an explicit ColumnDefault object (such as via the 
"default" keyword, or a Sequence or PassiveDefault), then the value of autoincrement is ignored and is assumed 
to be False.  autoincrement value is only significant for a column with a type or subtype of Integer.

quote=False : indicates that the Column identifier must be properly escaped and quoted before being sent 
to the database.  This flag should normally not be required as dialects can auto-detect conditions where quoting
is required.

case_sensitive=True : indicates that the identifier should be interpreted by the database in the natural case for identifiers.
Mixed case is not sufficient to cause this identifier to be quoted; it must contain an illegal character.

Reimplemented from sqlalchemy::sql::_ColumnClause.

Definition at line 305 of file schema.py.

00305                                                    :
        """constructs a new Column object.  Arguments are:
        
        name : the name of this column.  this should be the identical name as it appears,
        or will appear, in the database.
        
        type: the TypeEngine for this column.
        This can be any subclass of types.AbstractType, including the database-agnostic types defined 
        in the types module, database-specific types defined within specific database modules, or user-defined types.
        
        *args: Constraint, ForeignKey, ColumnDefault and Sequence objects should be added as list values.
        
        **kwargs : keyword arguments include:
        
        key=None : an optional "alias name" for this column.  The column will then be identified everywhere
        in an application, including the column list on its Table, by this key, and not the given name.  
        Generated SQL, however, will still reference the column by its actual name.
        
        primary_key=False : True if this column is a primary key column.  Multiple columns can have this flag
        set to specify composite primary keys.  As an alternative, the primary key of a Table can be specified
        via an explicit PrimaryKeyConstraint instance appended to the Table's list of objects.
        
        nullable=True : True if this column should allow nulls. Defaults to True unless this column is a primary
        key column.
        
        default=None : a scalar, python callable, or ClauseElement representing the "default value" for this column,
        which will be invoked upon insert if this column is not present in the insert list or is given a value
        of None.  The default expression will be converted into a ColumnDefault object upon initialization.

        _is_oid=False : used internally to indicate that this column is used as the quasi-hidden "oid" column

        index=False : Indicates that this column is
        indexed. The name of the index is autogenerated.
        to specify indexes with explicit names or indexes that contain multiple 
        columns, use the Index construct instead.

        unique=False : Indicates that this column 
        contains a unique constraint, or if index=True as well, indicates
        that the Index should be created with the unique flag.
        To specify multiple columns in the constraint/index or to specify an 
        explicit name, use the UniqueConstraint or Index constructs instead.

        autoincrement=True : Indicates that integer-based primary key columns should have autoincrementing behavior,
        if supported by the underlying database.  This will affect CREATE TABLE statements such that they will
        use the databases "auto-incrementing" keyword (such as SERIAL for postgres, AUTO_INCREMENT for mysql) and will
        also affect the behavior of some dialects during INSERT statement execution such that they will assume primary 
        key values are created in this manner.  If a Column has an explicit ColumnDefault object (such as via the 
        "default" keyword, or a Sequence or PassiveDefault), then the value of autoincrement is ignored and is assumed 
        to be False.  autoincrement value is only significant for a column with a type or subtype of Integer.
        
        quote=False : indicates that the Column identifier must be properly escaped and quoted before being sent 
        to the database.  This flag should normally not be required as dialects can auto-detect conditions where quoting
        is required.

        case_sensitive=True : indicates that the identifier should be interpreted by the database in the natural case for identifiers.
        Mixed case is not sufficient to cause this identifier to be quoted; it must contain an illegal character.
        """
        name = str(name) # in case of incoming unicode        
        super(Column, self).__init__(name, None, type)
        self.args = args
        self.key = kwargs.pop('key', name)
        self._primary_key = kwargs.pop('primary_key', False)
        self.nullable = kwargs.pop('nullable', not self.primary_key)
        self._is_oid = kwargs.pop('_is_oid', False)
        self.default = kwargs.pop('default', None)
        self.index = kwargs.pop('index', None)
        self.unique = kwargs.pop('unique', None)
        self.quote = kwargs.pop('quote', False)
        self._set_casing_strategy(name, kwargs)
        self.onupdate = kwargs.pop('onupdate', None)
        self.autoincrement = kwargs.pop('autoincrement', True)
        self.constraints = util.Set()
        self.__originating_column = self
        self._foreign_keys = util.OrderedSet()
        if len(kwargs):
            raise exceptions.ArgumentError("Unknown arguments passed to Column: " + repr(kwargs.keys()))

    primary_key = util.SimpleProperty('_primary_key')


Generated by  Doxygen 1.6.0   Back to index