SQLAlchemy 0.3 Documentation

Multiple Pages | One Page
Version: 0.3.10 Last Updated: 07/20/07 17:20:04

module sqlalchemy.databases.mysql

Module Functions

def descriptor()

class MSBigInteger(MSInteger)

MySQL BIGINTEGER type

def __init__(self, length=None, **kw)

Construct a BIGINTEGER.

length
Optional, maximum display width for this number.
unsigned
Optional.
zerofill
Optional. If true, values will be stored as strings left-padded with zeros. Note that this does not effect the values returned by the underlying database API, which continue to be numeric.
def get_col_spec(self)
back to section top

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 not length is specified, this will generate a BLOB. This usage is deprecated.
def convert_result_value(self, value, dialect)
def get_col_spec(self)
back to section top

class 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.
def convert_result_value(self, value, dialect)
def get_col_spec(self)
back to section top

class MSBoolean(Boolean)

def convert_bind_param(self, value, dialect)
def convert_result_value(self, value, dialect)
def get_col_spec(self)
back to section top

class MSChar(_StringType,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.
def get_col_spec(self)
back to section top

class MSDate(Date)

MySQL DATE type

def get_col_spec(self)
back to section top

class MSDateTime(DateTime)

MySQL DATETIME type

def get_col_spec(self)
back to section top

class MSDecimal(MSNumeric)

MySQL DECIMAL type

def __init__(self, precision=10, length=2, **kw)

Construct a DECIMAL.

precision
Total digits in this number. If length and precision are both None, values are stored to limits allowed by the server.
length
The number of digits after the decimal point.
unsigned
Optional.
zerofill
Optional. If true, values will be stored as strings left-padded with zeros. Note that this does not effect the values returned by the underlying database API, which continue to be numeric.
def get_col_spec(self)
back to section top

class MSDouble(MSNumeric)

MySQL DOUBLE type

def __init__(self, precision=10, length=2, **kw)

Construct a DOUBLE.

precision
Total digits in this number. If length and precision are both None, values are stored to limits allowed by the server.
length
The number of digits after the decimal point.
unsigned
Optional.
zerofill
Optional. If true, values will be stored as strings left-padded with zeros. Note that this does not effect the values returned by the underlying database API, which continue to be numeric.
def get_col_spec(self)
back to section top

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
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 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.
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.
def convert_bind_param(self, value, engine)
def get_col_spec(self)
back to section top

class MSFloat(Float,_NumericType)

MySQL FLOAT type

def __init__(self, precision=10, length=None, **kw)

Construct a FLOAT.

precision
Total digits in this number. If length and precision are both None, values are stored to limits allowed by the server.
length
The number of digits after the decimal point.
unsigned
Optional.
zerofill
Optional. If true, values will be stored as strings left-padded with zeros. Note that this does not effect the values returned by the underlying database API, which continue to be numeric.
def get_col_spec(self)
back to section top

class MSInteger(Integer,_NumericType)

MySQL INTEGER type

def __init__(self, length=None, **kw)

Construct an INTEGER.

length
Optional, maximum display width for this number.
unsigned
Optional.
zerofill
Optional. If true, values will be stored as strings left-padded with zeros. Note that this does not effect the values returned by the underlying database API, which continue to be numeric.
def get_col_spec(self)
back to section top

class MSLongBlob(MSBlob)

MySQL LONGBLOB type, for binary data up to 2^32 bytes

def get_col_spec(self)
back to section top

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.
def get_col_spec(self)
back to section top

class MSMediumBlob(MSBlob)

MySQL MEDIUMBLOB type, for binary data up to 2^24 bytes

def get_col_spec(self)
back to section top

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.
def get_col_spec(self)
back to section top

class MSNChar(_StringType,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.
def get_col_spec(self)
back to section top

class MSNVarChar(_StringType,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.
def get_col_spec(self)
back to section top

class MSNumeric(Numeric,_NumericType)

MySQL NUMERIC type

def __init__(self, precision=10, length=2, **kw)

Construct a NUMERIC.

precision
Total digits in this number. If length and precision are both None, values are stored to limits allowed by the server.
length
The number of digits after the decimal point.
unsigned
Optional.
zerofill
Optional. If true, values will be stored as strings left-padded with zeros. Note that this does not effect the values returned by the underlying database API, which continue to be numeric.
def get_col_spec(self)
back to section top

class MSSmallInteger(SmallInteger,_NumericType)

MySQL SMALLINTEGER type

def __init__(self, length=None, **kw)

Construct a SMALLINTEGER.

length
Optional, maximum display width for this number.
unsigned
Optional.
zerofill
Optional. If true, values will be stored as strings left-padded with zeros. Note that this does not effect the values returned by the underlying database API, which continue to be numeric.
def get_col_spec(self)
back to section top

class MSString(_StringType,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.
def get_col_spec(self)
back to section top

class MSText(_StringType,TEXT)

MySQL TEXT type, for text up to 2^16 characters

def __init__(self, length=None, **kwargs)

Construct a TEXT.

length
Optional, if provided the server may optimize storage by subsitituting the smallest TEXT type sufficient to store length 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.
def get_col_spec(self)
back to section top

class MSTime(Time)

MySQL TIME type

def convert_result_value(self, value, dialect)
def get_col_spec(self)
back to section top

class MSTimeStamp(TIMESTAMP)

MySQL TIMESTAMP type

To signal the orm to automatically re-select modified rows to retrieve the timestamp, add a PassiveDefault to your column specification:

from sqlalchemy.databases import mysql Column('updated', mysql.MSTimeStamp, PassiveDefault(text('CURRENT_TIMESTAMP()')))
def get_col_spec(self)
back to section top

class MSTinyBlob(MSBlob)

MySQL TINYBLOB type, for binary data up to 2^8 bytes

def get_col_spec(self)
back to section top

class MSTinyText(MSText)

MySQL TINYTEXT type, for text up to 2^8 characters

def __init__(self, **kwargs)

Construct a TINYTEXT.

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.
def get_col_spec(self)
back to section top

class 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.
def get_col_spec(self)
back to section top

class MSYear(String)

MySQL YEAR type, for single byte storage of years 1901-2155

def get_col_spec(self)
back to section top

class MySQLCompiler(ANSICompiler)

def binary_operator_string(self, binary)
def for_update_clause(self, select)
def limit_clause(self, select)
def visit_cast(self, cast)
back to section top

class MySQLDialect(ANSIDialect)

def __init__(self, **kwargs)
def compiler(self, statement, bindparams, **kwargs)
def create_connect_args(self, url)
def create_execution_context(self, *args, **kwargs)
def dbapi(cls)
def do_execute(self, cursor, statement, parameters, **kwargs)
def do_executemany(self, cursor, statement, parameters, context=None, **kwargs)
def do_rollback(self, connection)
def get_default_schema_name(self, connection)
def get_version_info(self, connectable)
def has_table(self, connection, table_name, schema=None)
def is_disconnect(self, e)
def max_identifier_length(self)
def moretableinfo(self, connection, table, charset=None)

SHOW CREATE TABLE to get foreign key/table options.

def preparer(self)
def reflecttable(self, connection, table)

Load column definitions from the server.

def schemadropper(self, *args, **kwargs)
def schemagenerator(self, *args, **kwargs)
def supports_sane_rowcount(self)
def supports_unicode_statements(self)
def type_descriptor(self, typeobj)
back to section top

class MySQLExecutionContext(DefaultExecutionContext)

def post_exec(self)
back to section top

class MySQLIdentifierPreparer(ANSIIdentifierPreparer)

def __init__(self, dialect)
back to section top

class MySQLSchemaDropper(ANSISchemaDropper)

def drop_foreignkey(self, constraint)
def visit_index(self, index)
back to section top

class MySQLSchemaGenerator(ANSISchemaGenerator)

def get_column_specification(self, column, override_pk=False, first_pk=False)
def post_create_table(self, table)
back to section top

class array(object)

array(typecode [, initializer]) -> array

Return a new array whose items are restricted by typecode, and initialized from the optional initializer value, which must be a list, string. or iterable over elements of the appropriate type.

Arrays represent basic values and behave very much like lists, except the type of objects stored in them is constrained.

Methods:

append() -- append a new item to the end of the array buffer_info() -- return information giving the current memory info byteswap() -- byteswap all the items of the array count() -- return number of occurences of an object extend() -- extend array by appending multiple elements from an iterable fromfile() -- read items from a file object fromlist() -- append items from the list fromstring() -- append items from the string index() -- return index of first occurence of an object insert() -- insert a new item into the array at a provided position pop() -- remove and return item (default last) read() -- DEPRECATED, use fromfile() remove() -- remove first occurence of an object reverse() -- reverse the order of the items in the array tofile() -- write all items to a file object tolist() -- return the array converted to an ordinary list tostring() -- return the array converted to a string write() -- DEPRECATED, use tofile()

Attributes:

typecode -- the typecode character used to create the array itemsize -- the length in bytes of one array item

itemsize = property()

the size, in bytes, of one array item

typecode = property()

the typecode character used to create the array

back to section top
Up: Generated Documentation | Previous: module sqlalchemy.databases.postgres | Next: module sqlalchemy.databases.oracle