cartoframes.batch module¶
Batch SQL API functionality for longer running operations
-
class
cartoframes.batch.BatchJobStatus(carto_context, job)¶ Bases:
objectStatus of a write or query operation. Read more at Batch SQL API docs about responses and how to interpret them.
Example
Poll for a job’s status if you’ve caught the
BatchJobStatusinstance.import time job = cc.write(df, 'new_table', lnglat=('lng_col', 'lat_col')) while True: curr_status = job.status()['status'] if curr_status in ('done', 'failed', 'canceled', 'unknown', ): print(curr_status) break time.sleep(5)
Create a
BatchJobStatusinstance if you have a job_id output from aCartoContext.writeoperation.>>> from cartoframes import CartoContext, BatchJobStatus >>> cc = CartoContext(username='...', api_key='...') >>> cc.write(df, 'new_table', lnglat=('lng', 'lat')) 'BatchJobStatus(job_id='job-id-string', ...)' >>> batch_job = BatchJobStatus(cc, 'job-id-string')
-
job_id¶ Job ID of the Batch SQL API job
Type: str
-
last_status¶ Status of
job_idjob when last polledType: str
-
created_at¶ Time and date when job was created
Type: str
Parameters: - carto_context (
CartoContext) –CartoContextinstance - job (dict or str) – If a dict, job status dict returned after sending a Batch SQL API request. If str, a Batch SQL API job id.
-
get_status()¶ return current status of job
-
status()¶ Checks the current status of job
job_idReturns: Status and time it was updated Return type: dict Warns: UserWarning – If the job failed, a warning is raised with information about the failure
-