diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2005-09-22 05:24:12 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2005-09-22 05:24:12 +0000 |
commit | b049d03a70a5938f8ae922f3538b606804b22b8f (patch) | |
tree | 868a86a44ddffa111ac1472780af5d3dd284ff4f /lib/sqlalchemy | |
parent | b822985ead5da6a8099962a8c3e2cb50cac8115d (diff) | |
download | sqlalchemy-b049d03a70a5938f8ae922f3538b606804b22b8f.tar.gz |
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r-- | lib/sqlalchemy/types.py | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/lib/sqlalchemy/types.py b/lib/sqlalchemy/types.py new file mode 100644 index 000000000..a138eb4c8 --- /dev/null +++ b/lib/sqlalchemy/types.py @@ -0,0 +1,71 @@ +__ALL__ = [ + 'INT', 'CHAR', 'VARCHAR', 'TEXT', 'FLOAT', 'DECIMAL', + 'TIMESTAMP', 'DATETIME', 'CLOB', 'BLOB', 'BOOLEAN', 'String', 'Integer', 'Numeric', 'DateTime', 'Binary', + ] + + +class TypeEngineMeta(type): + def convert_bind_param(cls, value): + return cls.singleton.convert_bind_param(value) + def convert_result_value(cls, value): + return cls.singleton.convert_result_value(value) + +class TypeEngine(object): + __metaclass__ = TypeEngineMeta + def get_col_spec(self): + raise NotImplementedError() + def convert_bind_param(self, value): + raise NotImplementedError() + def convert_result_value(self, value): + raise NotImplementedError() + +class NullTypeEngine(TypeEngine): + def get_col_spec(self): + raise NotImplementedError() + def convert_bind_param(self, value): + return value + def convert_result_value(self, value): + return value + +class String(TypeEngine): + def __init__(self, length): + self.length = length +String.singleton = String(-1) + +class Integer(TypeEngine): + """integer datatype""" + pass +Integer.singleton = Integer() + +class Numeric(TypeEngine): + def __init__(self, precision, length): + self.precision = precision + self.length = length +Numeric.singleton = Numeric(10, 2) + +class DateTime(TypeEngine): + pass +DateTime.singleton = DateTime() + +class Binary(TypeEngine): + pass +Binary.singleton = Binary() + +class Boolean(TypeEngine): + pass +Boolean.singleton = Boolean() + +class FLOAT(Numeric):pass +class TEXT(String): pass +class DECIMAL(Numeric):pass +class INT(Integer):pass +INTEGER = INT +class TIMESTAMP(DateTime): pass +class DATETIME(DateTime): pass +class CLOB(String): pass +class VARCHAR(String): pass +class CHAR(String):pass +class BLOB(Binary): pass +class BOOLEAN(Boolean): pass + + |