コード例 #1
0
 def __init__(self, settings):  
     # instantiates Engine() class
     # and DatabaseOps() class, if writing to CSV (name convention seems counter intuitive)
     self.settings = settings
     self.engine = Engine(settings)
     self.write_to_db = settings.WRITE_TO_DB
     
     if settings.WRITE_TO_DB:
         self.db = Database()
     else:
         self.db = None
         self.new_file = open('%s.csv' % (self.engine.tablename), 'w')
         
         dbops = DatabaseOps()
         dbops.import_classes(self.engine.sql_cols, self.engine.sql_declare)
         self.new_file.write(dbops.build_csv('|', True))
コード例 #2
0
 def process_result(result):
     
     #s = Settings() #mostly a static variable class
     args = get_result_list(KeyArgs.record, result)
     
     if args != None:
         data = KeyArgs.engine.init_cls(args)
         sql_cols = KeyArgs.engine.init_cls(KeyArgs.engine.sql_cols_list)
         
         sql = DatabaseOps()
         sql.import_classes(sql_cols, data, self.settings.INCLUDE_IDS)
         
         if KeyArgs.db != None:
             KeyArgs.db.query(sql.build_insert())
         else:
             line = sql.build_csv()
             print line
             KeyArgs.new_file.write(line)
         self.counter()