This table give a comprehensive list of the SQL Types that are expected to be supported by the database backends. If the type is not supported then the backend will have to emulate the behavior described here.
The columns are in the following order:
[1] | Corresponding to the SQL 92 standard or to a PostgreSQL type. |
None will represent the NULL value and vice versa, it can be used as input or output for any SQL type.
SQL Type | Python input type | Python output type |
---|---|---|
BOOL | bool | bool |
INTEGER | int | int |
BIGINT | int / long [2] | int / long [2] |
FLOAT | float / int / long [2] | float |
NUMERIC | decimal.Decimal | decimal.Decimal |
VARCHAR / VARCHAR(length) | str / unicode [3] | str / unicode [3] |
TEXT | str / unicode [3] | str / unicode [3] |
TIMESTAMP | datetime.datetime | datetime.datetime |
DATETIME | datetime.datetime without microseconds [4] | datetime.datetime without microseconds [4] |
DATE | datetime.date | datetime.date |
TIME | datetime.time | datetime.time |
INTERVAL | datetime.timedelta | datetime.timedelta |
BLOB | bytes | bytes |
[2] | (1, 2, 3) in python 2 integers over sys.maxint are represented by the long type |
[3] | (1, 2, 3, 4) str when using python 3 ; unicode when using python 2 |
[4] | (1, 2) Datetime objects are not localized to any timezone |