SQLAlchemy 0.4 Documentation
- class AbstractType(object)
- class BLOB(Binary)
- class BOOLEAN(Boolean)
- class Binary(TypeEngine)
- class Boolean(TypeEngine)
- class CHAR(String)
- class CLOB(Text)
- class DATE(Date)
- class DATETIME(DateTime)
- class DECIMAL(Numeric)
- class Date(TypeEngine)
- class DateTime(TypeEngine)
- class FLOAT(Float)
- class Float(Numeric)
- class INT(Integer)
- class Integer(TypeEngine)
- class Interval(TypeDecorator)
- class NCHAR(Unicode)
- class NUMERIC(Numeric)
- class Numeric(TypeEngine)
- class PickleType(MutableType,TypeDecorator)
- class SMALLINT(SmallInteger)
- class SmallInteger(Integer)
- class String(Concatenable,TypeEngine)
- class TIME(Time)
- class TIMESTAMP(DateTime)
- class Text(String)
- class Time(TypeEngine)
- class TypeDecorator(AbstractType)
- class TypeEngine(AbstractType)
- class Unicode(String)
- class UnicodeText(Text)
- class VARCHAR(String)
module sqlalchemy.types
defines genericized SQL types, each represented by a subclass of AbstractType. Dialects define further subclasses of these types.
For more information see the SQLAlchemy documentation on types.
class AbstractType(object)
given an operator from the sqlalchemy.sql.operators package, translate it to a new operator based on the semantics of this type.
By default, returns the operator unchanged.
Legacy convert_bind_param() compatability method.
This adapter method is provided for user-defined types that implement the older convert_* interface and need to call their super method. These calls are adapted behind the scenes to use the newer callable-based interface via bind_processor().
Compatibility is configured on a case-by-case basis at class definition time by a legacy adapter metaclass. This method is only available and functional if the concrete subclass implements the legacy interface.
Legacy convert_result_value() compatibility method.
This adapter method is provided for user-defined types that implement the older convert_* interface and need to call their super method. These calls are adapted behind the scenes to use the newer callable-based interface via result_processor().
Compatibility is configured on a case-by-case basis at class definition time by a legacy adapter metaclass. This method is only available and functional if the concrete subclass implements the legacy interface.
Return the corresponding type object from the underlying DB-API, if any.
This can be useful for calling setinputsizes(), for example.
return True if the target Python type is 'mutable'.
This allows systems like the ORM to know if an object can be considered 'not changed' by identity alone.
class BLOB(Binary)
back to section topclass BOOLEAN(Boolean)
back to section topclass Binary(TypeEngine)
back to section topclass Boolean(TypeEngine)
back to section topclass CHAR(String)
back to section topclass CLOB(Text)
back to section topclass DATE(Date)
back to section topclass DATETIME(DateTime)
back to section topclass DECIMAL(Numeric)
back to section topclass FLOAT(Float)
back to section topclass Float(Numeric)
back to section topclass INT(Integer)
back to section topclass Interval(TypeDecorator)
Type to be used in Column statements to store python timedeltas.
If it's possible it uses native engine features to store timedeltas (now it's only PostgreSQL Interval type), if there is no such it fallbacks to DateTime storage with converting from/to timedelta on the fly
Converting is very simple - just use epoch(zero timestamp, 01.01.1970) as base, so if we need to store timedelta = 1 day (24 hours) in database it will be stored as DateTime = '2nd Jan 1970 00:00', see bind_processor and result_processor to actual conversion code
class NCHAR(Unicode)
back to section topclass NUMERIC(Numeric)
back to section topclass Numeric(TypeEngine)
Numeric datatype, usually resolves to DECIMAL or NUMERIC.
class PickleType(MutableType,TypeDecorator)
Construct a new PickleType.
class SMALLINT(SmallInteger)
back to section topclass String(Concatenable,TypeEngine)
A sized string type.
Usually corresponds to VARCHAR. Can also take Python unicode objects and encode to the database's encoding in bind params (and the reverse for result sets.)
a String with no length will adapt itself automatically to a Text object at the dialect level (this behavior is deprecated in 0.4).
class TIME(Time)
back to section topclass TIMESTAMP(DateTime)
back to section topclass TypeDecorator(AbstractType)
Allows the creation of types which add additional functionality to an existing type. Typical usage:
class MyCustomType(TypeDecorator):
impl = String
def process_bind_param(self, value, dialect):
return value + "incoming string"
def process_result_value(self, value, dialect):
return value[0:-16]
The class-level "impl" variable is required, and can reference any TypeEngine class. Alternatively, the load_dialect_impl() method can be used to provide different type classes based on the dialect given; in this case, the "impl" variable can reference TypeEngine as a placeholder.
loads the dialect-specific implementation of this type.
by default calls dialect.type_descriptor(self.impl), but can be overridden to provide different behavior.
class TypeEngine(AbstractType)
return a list of classes to test for a match when adapting this type to a dialect-specific type.
class Unicode(String)
A synonym for String(length, convert_unicode=True, assert_unicode='warn').
class UnicodeText(Text)
A synonym for Text(convert_unicode=True, assert_unicode='warn').
