Create PostGIS geometric objects

def _createGeometry(self, session, spatialReferenceID):
        """
        Create PostGIS geometric objects
        """
        # Flush the current session
        session.flush()

        # Create geometry for each fluvial link
        for link in self.getFluvialLinks():

            # Retrieve the nodes for each link
            nodes = link.nodes
            nodeCoordinates = []

            # Create geometry for each node
            for node in nodes:
                # Assemble coordinates in well known text format
                coordinates = '{0} {1} {2}'.format(node.x, node.y, node.elevation)
                nodeCoordinates.append(coordinates)

                # Create well known text string for point with z coordinate
                wktPoint = 'POINT Z ({0})'.format(coordinates)

                # Write SQL statement
                statement = self._getUpdateGeometrySqlString(geometryID=node.id,
                                                             tableName=node.tableName,
                                                             spatialReferenceID=spatialReferenceID,
                                                             wktString=wktPoint)

                session.execute(statement)

            # Assemble line string in well known text format
            wktLineString = 'LINESTRING Z ({0})'.format(', '.join(nodeCoordinates))

            # Write SQL statement
            statement = self._getUpdateGeometrySqlString(geometryID=link.id,
                                                         tableName=link.tableName,
                                                         spatialReferenceID=spatialReferenceID,
                                                         wktString=wktLineString)

            session.execute(statement)