![]() |
Python Connector for PostgreSQL Data types - Python Connector for PostgreSQL |
![]() |
The following table describes the supported PostgreSQL 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.
PostgreSQL data type | Type code | Python data type |
---|---|---|
character |
507 |
str |
character varying |
508 |
str |
text |
517 |
str |
smallint |
515 |
int |
integer |
511 |
int |
bigint |
501 |
int |
serial |
516 |
int |
bigserial |
502 |
int |
real |
514 |
float |
double precision |
510 |
float |
numeric |
513 |
|
date |
509 |
datetime.date |
time |
518 |
datetime.time |
time with time zone |
519 |
datetime.time |
timestamp |
520 |
datetime.datetime |
timestamp with time zone |
521 |
datetime.datetime |
bytea |
506 |
|
point |
562 |
|
lseg |
559 |
|
line |
558 |
|
path |
561 |
|
polygon |
563 |
|
box |
553 |
|
circle |
555 |