The following table describes the supported MongoDB data types and their mapping to the Python data types. The type codes returned in the description cursor attribute can be used in the addtypecast() cursor method.
| MongoDB data type | Type code | Python data type |
|---|---|---|
|
INTEGER |
5010 |
int |
|
INT64 |
5013 |
float |
|
FLOAT |
5016 |
float |
|
DATETIME |
5024 |
datetime.datetime |
|
STRING |
5003 |
str |
|
BYTES |
5028 |
bytes |
|
BOOLEAN |
5027 |
bool |
|
DOCUMENT |
1623 |
document |