def insert_supplier(name, location, category, phone, closing): ## can insert or update supplier_dashboard_fragment print('Creating Supplier') id_supplier = str(uuid.uuid1()) task = Entity() task.PartitionKey = name task.RowKey = id_supplier task.location = location print(location) location_data = geolocator.geocode(location) task.lat = location_data.latitude task.long = location_data.longitude task.category = category task.phone = phone task.closing = closing table_service.insert_or_replace_entity(SUPPLIER_TABLE, task) print('Created in Supplier: {name} with uuid {uuid}'.format( name=name, uuid=id_supplier))
def create_entity(station: WeatherStationTuple) -> dict: """ Conversion from input data to desired properties and types """ entity = Entity() entity.provider = 'bom' entity.country = 'Australia' entity.country_code = 'AU' entity.state = station.state entity.site = station.site entity.name = station.name entity.start_year = station.start_year entity.end_year = station.end_year location = { 'type': "point", 'coordinates': [float(station.longitude), float(station.latitude)] } entity.location = json.dumps(location) entity.PartitionKey = f"{entity.country_code}.{entity.state}" entity.RowKey = entity.site return entity