예제 #1
0
    def add(self, link):
        """Add a new link. Need to open vector map in write mode

        :param link: the Link to add to the DBlinks
        :type link: a Link object

         >>> from grass.pygrass.vector import VectorTopo
         >>> test_vect = VectorTopo(test_vector_name)
         >>> test_vect.open(mode='r')
         >>> dblinks = DBlinks(test_vect.c_mapinfo)
         >>> dblinks
         DBlinks([Link(1, table_doctest_map, sqlite)])
         >>> link = Link(2, 'pg_link', test_vector_name, 'cat',
         ...             'host=localhost dbname=grassdb', 'pg') # doctest: +SKIP
         >>> dblinks.add(link)                             # doctest: +SKIP
         >>> dblinks                                       # doctest: +SKIP
         DBlinks([Link(1, table_doctest_map, sqlite)])

        """
        # TODO: check if open in write mode or not.
        libvect.Vect_map_add_dblink(
            self.c_mapinfo,
            link.layer,
            link.name,
            link.table_name,
            link.key,
            link.database,
            link.driver,
        )
예제 #2
0
    def add(self, link):
        """Add a new link. ::

            >>> from pygrass.vector import VectorTopo
            >>> municip = VectorTopo('boundary_municp_sqlite')
            >>> municip.open()
            >>> dblinks = DBlinks(municip.c_mapinfo)
            >>> dblinks
            DBlinks([Link(1, boundary_municp, sqlite)])
            >>> link = Link(2, 'pg_link', 'boundary_municp_pg', 'cat',
            ...             'host=localhost dbname=grassdb', 'pg')
            >>> dblinks.add(link)
            >>> dblinks   # need to open vector map in write mode
            DBlinks([Link(1, boundary_municp, sqlite)])

        ..
        """
        #TODO: check if open in write mode or not.
        libvect.Vect_map_add_dblink(self.c_mapinfo, link.number, link.name,
                                    link.table_name, link.key, link.database,
                                    link.driver)