Beispiel #1
0
    def save(self,
             changed_data,
             columns_info,
             client_primary_key='__temp_PK',
             default_conn=None):
        """
        This function is used to save the data into the database.
        Depending on condition it will either update or insert the
        new row into the database.

        Args:
            changed_data: Contains data to be saved
            columns_info:
            default_conn:
            client_primary_key:
        """
        driver = get_driver(PG_DEFAULT_DRIVER)
        if default_conn is None:
            manager = driver.connection_manager(self.sid)
            conn = manager.connection(did=self.did, conn_id=self.conn_id)
        else:
            conn = default_conn

        return save_changed_data(changed_data=changed_data,
                                 columns_info=columns_info,
                                 command_obj=self,
                                 client_primary_key=client_primary_key,
                                 conn=conn)
Beispiel #2
0
    def save(self,
             changed_data,
             columns_info,
             client_primary_key='__temp_PK',
             default_conn=None):
        if not self.is_updatable_resultset:
            return False, gettext('Resultset is not updatable.'), None, None
        else:
            driver = get_driver(PG_DEFAULT_DRIVER)
            if default_conn is None:
                manager = driver.connection_manager(self.sid)
                conn = manager.connection(did=self.did, conn_id=self.conn_id)
            else:
                conn = default_conn

            return save_changed_data(changed_data=changed_data,
                                     columns_info=columns_info,
                                     conn=conn,
                                     command_obj=self,
                                     client_primary_key=client_primary_key,
                                     auto_commit=self.auto_commit)