What is the right way to insert a Point to a PostGIS database using Python?
First, install the psycopg2 package, a Pythonic interface for PostgreSQL.
For more complicated geometries, such as LineString and Polygon geometries, you can handle them with Shapely, then pass them through psycopg2 as hex-encoded WKB. Note that Shapely 1.3 or later is required to handle the export of 3D geometries with the
Further note that similar can be accomplished by sending the geometry's WKT, however since it is converted to text, it is lossy and may reduce angstroms of precision. Transferring geometries as hex-encoded WKB is lossless, and preserves the exact precision of each coordinate.