src/dirbs/importer/base_delta_importer.py
def _add_into_historic_single_shard(self, src_shard_name, dest_shard_name, job_start_time,
                                        change_type='add'):
        """Add entries into historic table (if import supports IMEI sharding, is called once per shard)."""
        with utils.create_db_connection(self._db_config) as conn, conn.cursor() as cursor:
            if self._supports_imei_shards:
                virtual_imei_col = sql.SQL(', virt_imei_shard')
                virtual_imei_data = sql.SQL(', calc_virt_imei_shard(imei_norm)')
            else:
                virtual_imei_col = sql.SQL('')
                virtual_imei_data = sql.SQL('')

            cursor.execute(sql.SQL("""INSERT INTO {dest_shard} ({all_fields},
                                                                start_date, end_date{virtual_imei_col})
                                           SELECT {all_fields}, %s, NULL{virtual_imei_data}
                                             FROM {src_shard} n
                                            WHERE change_type = %s
                                                  ON CONFLICT ({pks}) WHERE (end_date IS NULL)
                                                  DO NOTHING""")  # noqa Q441
                           .format(pks=self._pk_field_columns,
                                   dest_shard=sql.Identifier(dest_shard_name),
                                   src_shard=sql.Identifier(src_shard_name),
                                   all_fields=self._output_field_columns,
                                   virtual_imei_col=virtual_imei_col,
                                   virtual_imei_data=virtual_imei_data),
                           [job_start_time, change_type])

            return change_type, cursor.rowcount
Add entries into historic table (if import supports IMEI sharding, is called once per shard).
Add entries into historic table (if import supports IMEI sharding, is called once per shard).
Add entries into historic table ( if import supports IMEI sharding is called once per shard ) .
def _add_into_historic_single_shard(self, src_shard_name, dest_shard_name, job_start_time,
                                        change_type='add'):
        with utils.create_db_connection(self._db_config) as conn, conn.cursor() as cursor:
            if self._supports_imei_shards:
                virtual_imei_col = sql.SQL(', virt_imei_shard')
                virtual_imei_data = sql.SQL(', calc_virt_imei_shard(imei_norm)')
            else:
                virtual_imei_col = sql.SQL('')
                virtual_imei_data = sql.SQL('')
            cursor.execute(sql.SQL("""INSERT INTO {dest_shard} ({all_fields},
                                                                start_date, end_date{virtual_imei_col})
                                           SELECT {all_fields}, %s, NULL{virtual_imei_data}
                                             FROM {src_shard} n
                                            WHERE change_type = %s
                                                  ON CONFLICT ({pks}) WHERE (end_date IS NULL)
                                                  DO NOTHING""")  
                           .format(pks=self._pk_field_columns,
                                   dest_shard=sql.Identifier(dest_shard_name),
                                   src_shard=sql.Identifier(src_shard_name),
                                   all_fields=self._output_field_columns,
                                   virtual_imei_col=virtual_imei_col,
                                   virtual_imei_data=virtual_imei_data),
                           [job_start_time, change_type])
            return change_type, cursor.rowcount
def _add_into_historic_single_shard ( self , src_shard_name , dest_shard_name , job_start_time , change_type = 'add' ) : with utils . create_db_connection ( self . _db_config ) as conn , conn . cursor ( ) as cursor : if self . _supports_imei_shards : virtual_imei_col = sql . SQL ( ', virt_imei_shard' ) virtual_imei_data = sql . SQL ( ', calc_virt_imei_shard(imei_norm)' ) else : virtual_imei_col = sql . SQL ( '' ) virtual_imei_data = sql . SQL ( '' ) cursor . execute ( sql . SQL ( """INSERT INTO {dest_shard} ({all_fields},
                                                                start_date, end_date{virtual_imei_col})
                                           SELECT {all_fields}, %s, NULL{virtual_imei_data}
                                             FROM {src_shard} n
                                            WHERE change_type = %s
                                                  ON CONFLICT ({pks}) WHERE (end_date IS NULL)
                                                  DO NOTHING""" ) . format ( pks = self . _pk_field_columns , dest_shard = sql . Identifier ( dest_shard_name ) , src_shard = sql . Identifier ( src_shard_name ) , all_fields = self . _output_field_columns , virtual_imei_col = virtual_imei_col , virtual_imei_data = virtual_imei_data ) , [ job_start_time , change_type ] ) return change_type , cursor . rowcount
Add entries into historic table (if import supports IMEI sharding, is called once per shard).
Add entries into historic table ( if import supports IMEI sharding is called once per shard ) .
"""Add entries into historic table (if import supports IMEI sharding, is called once per shard).""" # noqa Q441
self
src_shard_name
dest_shard_name
job_start_time
change_type