?? mysql.py
字號:
unicode Defaults to False: short-hand for the ``ucs2`` character set, generates UNICODE in schema. national Optional. If true, use the server's configured national character set. binary Defaults to False: short-hand, pick the binary collation type that matches the column's character set. Generates BINARY in schema. This does not affect the type of data stored, only the collation of character data. """ super(MSTinyText, self).__init__(**kwargs) def get_col_spec(self): return self._extend("TINYTEXT")class MSMediumText(MSText): """MySQL MEDIUMTEXT type, for text up to 2^24 characters.""" def __init__(self, **kwargs): """Construct a MEDIUMTEXT. charset Optional, a column-level character set for this string value. Takes precendence to 'ascii' or 'unicode' short-hand. collation Optional, a column-level collation for this string value. Takes precedence to 'binary' short-hand. ascii Defaults to False: short-hand for the ``latin1`` character set, generates ASCII in schema. unicode Defaults to False: short-hand for the ``ucs2`` character set, generates UNICODE in schema. national Optional. If true, use the server's configured national character set. binary Defaults to False: short-hand, pick the binary collation type that matches the column's character set. Generates BINARY in schema. This does not affect the type of data stored, only the collation of character data. """ super(MSMediumText, self).__init__(**kwargs) def get_col_spec(self): return self._extend("MEDIUMTEXT")class MSLongText(MSText): """MySQL LONGTEXT type, for text up to 2^32 characters.""" def __init__(self, **kwargs): """Construct a LONGTEXT. charset Optional, a column-level character set for this string value. Takes precendence to 'ascii' or 'unicode' short-hand. collation Optional, a column-level collation for this string value. Takes precedence to 'binary' short-hand. ascii Defaults to False: short-hand for the ``latin1`` character set, generates ASCII in schema. unicode Defaults to False: short-hand for the ``ucs2`` character set, generates UNICODE in schema. national Optional. If true, use the server's configured national character set. binary Defaults to False: short-hand, pick the binary collation type that matches the column's character set. Generates BINARY in schema. This does not affect the type of data stored, only the collation of character data. """ super(MSLongText, self).__init__(**kwargs) def get_col_spec(self): return self._extend("LONGTEXT")class MSString(_StringType, sqltypes.String): """MySQL VARCHAR type, for variable-length character data.""" def __init__(self, length=None, **kwargs): """Construct a VARCHAR. length Maximum data length, in characters. charset Optional, a column-level character set for this string value. Takes precendence to 'ascii' or 'unicode' short-hand. collation Optional, a column-level collation for this string value. Takes precedence to 'binary' short-hand. ascii Defaults to False: short-hand for the ``latin1`` character set, generates ASCII in schema. unicode Defaults to False: short-hand for the ``ucs2`` character set, generates UNICODE in schema. national Optional. If true, use the server's configured national character set. binary Defaults to False: short-hand, pick the binary collation type that matches the column's character set. Generates BINARY in schema. This does not affect the type of data stored, only the collation of character data. """ _StringType.__init__(self, **kwargs) sqltypes.String.__init__(self, length, kwargs.get('convert_unicode', False), kwargs.get('assert_unicode', None)) def get_col_spec(self): if self.length: return self._extend("VARCHAR(%d)" % self.length) else: return self._extend("TEXT")class MSChar(_StringType, sqltypes.CHAR): """MySQL CHAR type, for fixed-length character data.""" def __init__(self, length, **kwargs): """Construct an NCHAR. length Maximum data length, in characters. binary Optional, use the default binary collation for the national character set. This does not affect the type of data stored, use a BINARY type for binary data. collation Optional, request a particular collation. Must be compatibile with the national character set. """ _StringType.__init__(self, **kwargs) sqltypes.CHAR.__init__(self, length, kwargs.get('convert_unicode', False)) def get_col_spec(self): return self._extend("CHAR(%(length)s)" % {'length' : self.length})class MSNVarChar(_StringType, sqltypes.String): """MySQL NVARCHAR type. For variable-length character data in the server's configured national character set. """ def __init__(self, length=None, **kwargs): """Construct an NVARCHAR. length Maximum data length, in characters. binary Optional, use the default binary collation for the national character set. This does not affect the type of data stored, use a VARBINARY type for binary data. collation Optional, request a particular collation. Must be compatibile with the national character set. """ kwargs['national'] = True _StringType.__init__(self, **kwargs) sqltypes.String.__init__(self, length, kwargs.get('convert_unicode', False)) def get_col_spec(self): # We'll actually generate the equiv. "NATIONAL VARCHAR" instead # of "NVARCHAR". return self._extend("VARCHAR(%(length)s)" % {'length': self.length})class MSNChar(_StringType, sqltypes.CHAR): """MySQL NCHAR type. For fixed-length character data in the server's configured national character set. """ def __init__(self, length=None, **kwargs): """Construct an NCHAR. Arguments are: length Maximum data length, in characters. binary Optional, request the default binary collation for the national character set. collation Optional, request a particular collation. Must be compatibile with the national character set. """ kwargs['national'] = True _StringType.__init__(self, **kwargs) sqltypes.CHAR.__init__(self, length, kwargs.get('convert_unicode', False)) def get_col_spec(self): # We'll actually generate the equiv. "NATIONAL CHAR" instead of "NCHAR". return self._extend("CHAR(%(length)s)" % {'length': self.length})class _BinaryType(sqltypes.Binary): """Base for MySQL binary types.""" def get_col_spec(self): if self.length: return "BLOB(%d)" % self.length else: return "BLOB" def result_processor(self, dialect): def process(value): if value is None: return None else: return buffer(value) return processclass MSVarBinary(_BinaryType): """MySQL VARBINARY type, for variable length binary data.""" def __init__(self, length=None, **kw): """Construct a VARBINARY. Arguments are: length Maximum data length, in bytes. """ super(MSVarBinary, self).__init__(length, **kw) def get_col_spec(self): if self.length: return "VARBINARY(%d)" % self.length else: return "BLOB"class MSBinary(_BinaryType): """MySQL BINARY type, for fixed length binary data""" def __init__(self, length=None, **kw): """Construct a BINARY. This is a fixed length type, and short values will be right-padded with a server-version-specific pad value. length Maximum data length, in bytes. If length is not specified, this will generate a BLOB. This usage is deprecated. """ super(MSBinary, self).__init__(length, **kw) def get_col_spec(self): if self.length: return "BINARY(%d)" % self.length else: return "BLOB" def result_processor(self, dialect): def process(value): if value is None: return None else: return buffer(value) return processclass MSBlob(_BinaryType): """MySQL BLOB type, for binary data up to 2^16 bytes""" def __init__(self, length=None, **kw): """Construct a BLOB. Arguments are: length Optional, if provided the server may optimize storage by subsitituting the smallest TEXT type sufficient to store ``length`` characters. """ super(MSBlob, self).__init__(length, **kw) def get_col_spec(self): if self.length: return "BLOB(%d)" % self.length else: return "BLOB" def result_processor(self, dialect): def process(value): if value is None: return None else: return buffer(value) return process def __repr__(self): return "%s()" % self.__class__.__name__class MSTinyBlob(MSBlob): """MySQL TINYBLOB type, for binary data up to 2^8 bytes.""" def get_col_spec(self): return "TINYBLOB"class MSMediumBlob(MSBlob): """MySQL MEDIUMBLOB type, for binary data up to 2^24 bytes.""" def get_col_spec(self): return "MEDIUMBLOB"class MSLongBlob(MSBlob): """MySQL LONGBLOB type, for binary data up to 2^32 bytes.""" def get_col_spec(self): return "LONGBLOB"class MSEnum(MSString): """MySQL ENUM type.""" def __init__(self, *enums, **kw): """Construct an ENUM. Example: Column('myenum', MSEnum("'foo'", "'bar'", "'baz'")) Arguments are: enums The range of valid values for this ENUM. Values will be used exactly as they appear when generating schemas. Strings must be quoted, as in the example above. Single-quotes are suggested for ANSI compatability and are required for portability to servers with ANSI_QUOTES enabled. strict Defaults to False: ensure that a given value is in this ENUM's range of permissible values when inserting or updating rows. Note that MySQL will not raise a fatal error if you attempt to store an out of range value- an alternate value will be stored instead. (See MySQL ENUM documentation.) charset Optional, a column-level character set for this string
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -