Use Postgres advanced types in Python
Extending the support to other types is not straightforward, and involves the following steps:
- Create a Python class to store the data, e.g.
- Write a function to convert a
Pointto its SQL string representation, e.g.
- Write the inverse function to parse the SQL string representation of a
Pointand return and instance of a
- Finally bind all these functions and types, see
The complete code is as follows, also available as a gist: