import uuid ads_root = 'https://www.idealista.com/inmueble/' def create_capturing_task(referencia, db_wrapper, uuid_exploring=None): query_parameters = {'url': ads_root + referencia, 'uuid': str(uuid.uuid4()), 'status': 'Pending'} if uuid_exploring is None: query_statement = """INSERT INTO capturing_tasks_logs (uuid, write_time, status, url) VALUES (%(uuid)s, NOW(), %(status)s, url)""" else: query_statement = """INSERT INTO capturing_tasks_logs (uuid, write_time, status, url, fk_uuid_exploring) VALUES (%(uuid)s, NOW(), %(status)s, url, %(uuid_exploring))s""" query_parameters['uuid_exploring'] = uuid_exploring db_wrapper.query(query_statement, query_parameters)