def get_node(self, value):
        """Get node ID by value.

        If a node with the specified value does not exist,
        create it and return its ID.

        Parameters
        ----------
        value : `str`
            Node value.

        Returns
        -------
        `int`
            Node ID.
        """
        while True:
            self.cursor.execute(
                'SELECT id FROM nodes WHERE value=?',
                (value,)
            )
            node = self.cursor.fetchone()
            if node is not None:
                return node[0]
            self.cursor.execute(
                'INSERT INTO nodes (value) VALUES (?)',
                (value,)
            )
def get_node ( self , value ) : while True : self . cursor . execute ( 'SELECT id FROM nodes WHERE value=?' , ( value , ) ) node = self . cursor . fetchone ( ) if node is not None : return node [ 0 ] self . cursor . execute ( 'INSERT INTO nodes (value) VALUES (?)' , ( value , ) )
Get node ID by value.

        If a node with the specified value does not exist,
        create it and return its ID.

        Parameters
        ----------
        value : `str`
            Node value.

        Returns
        -------
        `int`
            Node ID.