Esempio n. 1
0
class ExtractWoocommerceProducts(ExtractWoocommerceDataToCSV):
    filename = 'products.csv'
    query = load_content_from_file('./sql/products.sql')

    def requires(self):
        yield CreateProductCategoryTable(self.date)
        yield CreateProductLastOrderTable(self.date)
Esempio n. 2
0
    def inner_run(self, connection, cursor):

        if self.query and self.query != '_load_from_input_':
            sqlFileContent = self.query
        else:
            sqlFileContent = load_content_from_file(self.input().path)

        # all SQL commands (split on ';\n' (newline))
        sqlCommands = re.split(";\n", sqlFileContent)

        # Execute every command from the input file
        for command in sqlCommands:
            if command.isspace():
                continue

            # This will skip and report errors
            # For example, if the tables do not yet exist, this will skip over
            # the DROP TABLE commands
            try:
                cursor.execute(command)
            except OperationalError, msg:
                print "Command skipped: ", msg
            except ProgrammingError, msg:
                raise Exception(
                    "ProgrammingError '{}' while executing following sql command: {}"
                    .format(msg, command))
Esempio n. 3
0
class ExtractWoocommerceStock(ExtractWoocommerceDataToCSV):
    filename = 'stock.csv'
    query = load_content_from_file('./sql/stock.sql')

    def write_row(self, output, row):
        l = list(row)
        l.append(str(self.date))
        output.write(*tuple(l))
Esempio n. 4
0
class ExtractCampaignTrackings(ExtractWoocommerceDataToCSV):
    filename = 'campaign_trackings.csv'
    query = load_content_from_file('./sql/campaign_trackings.sql')
Esempio n. 5
0
class ExtractWoocommerceOrders(ExtractWoocommerceDataToCSV):
    filename = 'orders.csv'
    query = load_content_from_file('./sql/orders.sql')
Esempio n. 6
0
class ExtractWoocommerceAddresses(ExtractWoocommerceDataToCSV):
    filename = 'addresses.csv'
    query = load_content_from_file('./sql/addresses.sql')
Esempio n. 7
0
class CreateProductLastOrderTable(MySQLTransformStepAfterImport):
    table = 'products__last_order_date'
    query = load_content_from_file('./sql/products__last_order_date.sql')
Esempio n. 8
0
class CreateProductCategoryTable(MySQLTransformStepAfterImport):
    table = 'category_tree'
    query = load_content_from_file('./sql/products__category_tree.sql')