示例#1
0
 def __init__(self):
     self.mysql_connection = mysql_connection.MysqlConnection()
     self.cd = customer_dict.CustomerDict()
     self.pn = purify_name.PurifyName()
     self.cc = customer_comparison.CustomerComparison()
     dealer_rows = self.mysql_connection.run("""
         select * from dealers
     """)
     self.dealer_sub = {row['legacy_id']: row['id'] for row in dealer_rows}
示例#2
0
    def run(self):
        # Connect
        self.mc = mysql_connection.MysqlConnection()
        rows = []
        for new_rows in self.generate_chunk():
            print('got new rows...{}'.format(len(new_rows)))
            rows.extend(new_rows)

        # Disconnect
        del(self.mc)
        return rows
示例#3
0
    def __call__(self, rows, timestamp):
        """ Insert the rows(as tuples, obv.)
            and then return the inserted ids """

        tuple_list = [
            self.helpers.dict_to_tuple(row, self.fields, timestamp)
            for row in rows
        ]

        self.mysql_connection = mysql_connection.MysqlConnection()
        self.mysql_connection.insert(self.get_insert_str(), tuple_list)
        del (self.mysql_connection)
示例#4
0
    def __call__(self, rows, timestamp):
        """ Insert the rows(as tuples, obv.)
            and then return the inserted ids """

        self.mysql_connection = mysql_connection.MysqlConnection()
        tuple_list = [
            self.helpers.dict_to_tuple(row, self.fields, timestamp)
            for row in rows
        ]
        self.mysql_connection.insert(self.get_insert_str(), tuple_list)

        results = self.mysql_connection.run("""SELECT id FROM customers
            order by id DESC LIMIT {}""".format(len(tuple_list)))

        customer_ids = [result['id'] for result in results]
        customer_ids.reverse()

        del (self.mysql_connection)
        return customer_ids
示例#5
0
    def __init__(self):
        logging.info('initializing materializer')
        self.config = config.Config()
        self.mysql_connection = mysql_connection.MysqlConnection()

        # Get Missing Timestamps (a callable class that is a generator)
        logging.info('getting all missing_timestamps')
        self.missing_timestamps = missing_timestamps.MissingTimestamps()

        logging.info(
            'initializing table_queries (get_all_rows_sale, get_all_rows_service)'
        )
        self.table_queries = {
            'sales': get_all_rows_sales.GetAllRowsSales(),
            'service': get_all_rows_service.GetAllRowsService()
        }

        logging.info('initializing subs')
        self.subs = [
            sub_dealers.SubDealers(),
            sub_vehicles.SubVehicles(),
            sub_customers.SubCustomers()
        ]
示例#6
0
 def __init__(self):
     self.mc = mysql_connection.MysqlConnection()
示例#7
0
 def __init__(self):
     self.mysql_connection = mysql_connection.MysqlConnection()
     dealer_rows = self.mysql_connection.run("""
         select * from dealers
     """)
     self.dealer_sub = {row['legacy_id']: row['id'] for row in dealer_rows}