Show
Ignore:
Timestamp:
08/19/07 04:05:09 (6 years ago)
Author:
ggpolo
Message:

Huge speed gain on XML insertion into databaseng, including insertion on Inventory and calculating changes.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branch/ggpolo/umitDB/Store.py

    r1400 r1431  
    5555                    scan_d["hosts_down"], scan_d["scanner"])) 
    5656 
    57         self.conn.commit() 
    58  
    5957     
    6058    def insert_scaninfo_db(self, scaninfo): 
     
    6967                        scaninfo["services"], scaninfo["fk_scan"], 
    7068                        scaninfo["type"], scaninfo["protocol"])) 
    71         self.conn.commit() 
    7269 
    7370 
     
    8077        self.cursor.execute("INSERT INTO scan_type (name) VALUES \ 
    8178                                 (?)", (scan_name, )) 
    82         self.conn.commit() 
    8379 
    8480 
     
    9187        self.cursor.execute("INSERT INTO scanner (name, version) VALUES \ 
    9288                                 (?, ?)", (scanner_name, scanner_version)) 
    93         self.conn.commit() 
    9489         
    9590 
     
    105100                       (portid, service_info_id, protocol_id, 
    106101                        port_state_id)) 
    107         self.conn.commit() 
    108102             
    109103     
     
    116110        self.cursor.execute("INSERT INTO port_state (state) VALUES \ 
    117111                                (?)", (port_state, )) 
    118         self.conn.commit() 
    119112     
    120113     
     
    127120        self.cursor.execute("INSERT INTO protocol (name) VALUES \ 
    128121                                 (?)", (protocol, )) 
    129         self.conn.commit() 
    130122         
    131123     
     
    138130        self.cursor.execute("INSERT INTO _host_port (fk_host, fk_port) \ 
    139131                    VALUES (?, ?)", (fk_host, fk_port)) 
    140         self.conn.commit() 
    141132         
    142133 
     
    150141                            fk_port_state) VALUES (?, ?, ?)", 
    151142                            (count, fk_host, fk_port_state)) 
    152         self.conn.commit() 
    153143 
    154144 
     
    163153                        fk_protocol, fk_host) VALUES (?, ?, ?, ?)", 
    164154                        (portid, fk_port_state, fk_protocol, fk_host)) 
    165         self.conn.commit() 
    166155 
    167156 
     
    177166                        (?, ?, ?, ?, ?, ?)", (osclass_accuracy, fk_osgen, 
    178167                        fk_osfamily, fk_osvendor, fk_ostype, fk_host)) 
    179         self.conn.commit() 
    180168 
    181169    
     
    190178                    fk_host) VALUES (?, ?, ?, ?)", (osmatch["name"],  
    191179                    osmatch["accuracy"], osmatch["line"], host)) 
    192         self.conn.commit() 
    193180         
    194181         
     
    200187         
    201188        self.cursor.execute("INSERT INTO osgen (gen) VALUES (?)", (osgen, )) 
    202         self.conn.commit() 
     189 
    203190         
    204191    def insert_osfamily_db(self, osfamily): 
     
    210197        self.cursor.execute("INSERT INTO osfamily (family) VALUES (?)",  
    211198                        (osfamily, )) 
    212         self.conn.commit() 
    213199             
    214200 
     
    221207        self.cursor.execute("INSERT INTO osvendor (vendor) VALUES (?)",  
    222208                        (osvendor, )) 
    223         self.conn.commit() 
    224209 
    225210     
     
    232217        self.cursor.execute("INSERT INTO ostype (type) VALUES (?)",  
    233218                        (ostype, )) 
    234         self.conn.commit() 
    235219         
    236220 
     
    244228                     fk_host_state) VALUES (?, ?, ?)", (host_d["distance"], 
    245229                     host_d["fk_scan"], host_d["fk_host_state"])) 
    246         self.conn.commit() 
    247230 
    248231 
     
    255238        self.cursor.execute("INSERT INTO _host_address (fk_host, fk_address) \ 
    256239                            VALUES (?, ?)", (fk_host, fk_address)) 
    257         self.conn.commit() 
    258240 
    259241 
     
    267249                                fk_hostname) VALUES (?, ?)", (fk_host,  
    268250                                fk_hostname)) 
    269         self.conn.commit() 
    270251     
    271252     
     
    279260                                 (?, ?)", (hostname["hostname_type"],  
    280261                                           hostname["hostname"])) 
    281         self.conn.commit() 
    282262    
    283263 
     
    302282                ip_id_sequence_value, fk_host) VALUES (?, ?, ?, ?, ?, ?, ?, \ 
    303283                ?, ?, ?, ?)", (data)) 
    304         self.conn.commit() 
    305284 
    306285     
     
    313292        self.cursor.execute("INSERT INTO service_name (name) VALUES \ 
    314293                            (?)", (service_name, )) 
    315         self.conn.commit() 
    316294         
    317295         
     
    325303                    extrainfo, method, conf, fk_service_name) VALUES (?, ?, ?,\ 
    326304                    ?, ?, ?)", service_data) 
    327         self.conn.commit() 
    328305         
    329306     
     
    337314                        fk_vendor) VALUES (?, ?, ?)", (address_addr, 
    338315                        address_type, vendor)) 
    339         self.conn.commit() 
    340316 
    341317     
     
    348324        self.cursor.execute("INSERT INTO vendor (name) \ 
    349325                                         VALUES (?)", (vendor_name, )) 
    350         self.conn.commit() 
    351326 
    352327         
     
    359334        self.cursor.execute("INSERT INTO host_state (state) \ 
    360335                        VALUES (?)", (host_state, )) 
    361         self.conn.commit() 
    362336 
    363337 
     
    372346                        tcpseq_dict["index"], tcpseq_dict["class"],  
    373347                        tcpseq_dict["difficulty"], tcpseq_dict["values"])) 
    374         self.conn.commit() 
    375348 
    376349 
     
    385358                      tcp_ts_values)  VALUES (?, ?)", (tcptsseq_dict["class"],  
    386359                      tcptsseq_dict["values"])) 
    387         self.conn.commit() 
    388360 
    389361 
     
    397369                      ip_id_values)  VALUES (?, ?)", (ipidseq_dict["class"],  
    398370                      ipidseq_dict["values"])) 
    399         self.conn.commit() 
    400371 
    401372 
     
    408379        self.cursor.execute("INSERT INTO inventory (name) VALUES (?)",  
    409380                    (inventory, )) 
    410         self.conn.commit() 
    411381         
    412382     
     
    419389        self.cursor.execute("INSERT INTO _inventory_scan (fk_scan, \ 
    420390                    fk_inventory) VALUES (?, ?)", (scan, inventory)) 
    421         self.conn.commit() 
    422391         
    423392         
     
    431400        self.cursor.execute("INSERT INTO inventory_change_category (name) \ 
    432401                             VALUES (?)", (category, )) 
    433         self.conn.commit() 
    434402         
    435403     
     
    448416                                                      short_descr, fk_inventory, 
    449417                                                      fk_category, fk_address)) 
    450         self.conn.commit() 
    451           
     418