Beispiel #1
0
        start_date = datetime.strptime(start_date_string, '%b %d %Y')
        end_date = datetime.strptime(end_date_string, '%b %d %Y')
        
        #Comment out azure SQL part as we decide to use Table Storage
        #cursor.execute('INSERT INTO [dbo].[Stores] \
        #                ([store_name],[start_date],[end_date],[description],[description_cn]) \
        #                values (?,?,?,?,?)', \
        #               store_name,start_date,end_date,description,description_cn)
        #cnxn.commit()

        #Insert data to Table Storage
        task = Entity()
        task.PartitionKey = 'Outlets'
        task.RowKey = store_name
        task.StartDate = start_date
        task.EndDate = end_date
        task.Description = description
        task.Description_CN = description_cn
        table_service.insert_entity('Outlets', task)
        
        print(store_name)
        print(start_date)
        print(end_date)
        print(description)
        print(description_cn)

    elif len(date_string.split(" ")) == 6:
        start_date_string = date_string.split(" ")[0] + ' ' + \
                            date_string.split(" ")[1] + ' ' + date_string.split(" ")[-1]
        end_date_string = date_string.split(" ")[3] + ' ' + \
                          date_string.split(" ")[4] + ' ' + date_string.split(" ")[-1]