Diff for /ZSQLExtend/importFMPXML.py between versions 1.10 and 1.11

version 1.10, 2007/04/05 14:20:08 version 1.11, 2007/04/18 15:09:52
Line 450  class xml_handler: Line 450  class xml_handler:
         return          return
   
   
   def importFMPXML(options):
       """SAX handler to import FileMaker XML file (FMPXMLRESULT format) into the table.     
           @param options: dict of options
           @param options.dsn: database connection string
           @param options.table: name of the table the xml shall be imported into
           @param options.filename: xmlfile filename
           @param options.update_fields: (optional) list of fields to update; default is to create all fields
           @param options.id_field: (optional) field which uniquely identifies an entry for updating purposes.
           @param options.sync_mode: (optional) really synchronise, i.e. delete entries not in XML file
           @param options.lc_names: (optional) lower case and clean up field names from XML
           @param options.keep_fields: (optional) don't add fields to SQL database
           @param options.ascii_db: (optional) assume ascii encoding in db
           @param options.replace_table: (optional) delete and re-insert data
           """
   
   
       if getattr(options,'update_fields',None):
           uf = {}
           for f in options.update_fields.split(','):
               (n,t) = f.split(':')
               uf[n] = TableColumn(n,t)
               
           options.update_fields = uf
       
       if getattr(options,'id_field',None) and getattr(options,'replace_table',None):
           logging.error("ABORT: sorry, you can't do both sync (id_field) and replace")
           sys.exit(1)
           
       parser = sax.make_parser()
       #The "consumer" is our own handler
       consumer = xml_handler(options)
       #Initialize Tenorsax with handler
       handler = saxtools.tenorsax(consumer)
       #Resulting tenorsax instance is the SAX handler 
       parser.setContentHandler(handler)
       parser.setFeature(sax.handler.feature_namespaces, 1)
       parser.parse(options.filename)  
       
   
 if __name__ == "__main__":  if __name__ == "__main__":
     from optparse import OptionParser      from optparse import OptionParser
Line 510  if __name__ == "__main__": Line 546  if __name__ == "__main__":
                         format='%(asctime)s %(levelname)s %(message)s',                          format='%(asctime)s %(levelname)s %(message)s',
                         datefmt='%H:%M:%S')                          datefmt='%H:%M:%S')
   
       importFMPXML(options)
   
 def importFMPXML(options):  
     """SAX handler to import FileMaker XML file (FMPXMLRESULT format) into the table.       
         @param options: dict of options  
         @param options.dsn: database connection string  
         @param options.table: name of the table the xml shall be imported into  
         @param options.filename: xmlfile filename  
         @param options.update_fields: (optional) list of fields to update; default is to create all fields  
         @param options.id_field: (optional) field which uniquely identifies an entry for updating purposes.  
         @param options.sync_mode: (optional) really synchronise, i.e. delete entries not in XML file  
         @param options.lc_names: (optional) lower case and clean up field names from XML  
         @param options.keep_fields: (optional) don't add fields to SQL database  
         @param options.ascii_db: (optional) assume ascii encoding in db  
         @param options.replace_table: (optional) delete and re-insert data  
         """  
      
       
     if getattr(options,'update_fields',None):  
         uf = {}  
         for f in options.update_fields.split(','):  
             (n,t) = f.split(':')  
             uf[n] = TableColumn(n,t)  
               
         options.update_fields = uf  
       
     if getattr(options,'id_field',None) and getattr(options,'replace_table',None):  
         logging.error("ABORT: sorry, you can't do both sync (id_field) and replace")  
         sys.exit(1)  
           
     parser = sax.make_parser()  
     #The "consumer" is our own handler  
     consumer = xml_handler(options)  
     #Initialize Tenorsax with handler  
     handler = saxtools.tenorsax(consumer)  
     #Resulting tenorsax instance is the SAX handler   
     parser.setContentHandler(handler)  
     parser.setFeature(sax.handler.feature_namespaces, 1)  
     parser.parse(options.filename)    
           
           
   

Removed from v.1.10  
changed lines
  Added in v.1.11


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>