Jobs¶
- 
class mindsdb_sdk.jobs.Job(project, name, data=None, create_callback=None)¶
- Bases: - object- 
add_query(query: Union[mindsdb_sdk.query.Query, str])¶
- Add a query to job. Method is used in context of the job - >>> with con.jobs.create('j1') as job: >>> job.add_query(table1.insert(table2)) - Parameters
- query – string or Query object. Query.database should be emtpy or the same as job’s project 
 
 - 
get_history() → pandas.core.frame.DataFrame¶
- Get history of job execution - Returns
- dataframe with job executions 
 
 - 
refresh()¶
- Retrieve job data from mindsdb server 
 
- 
- 
class mindsdb_sdk.jobs.Jobs(project, api)¶
- Bases: - mindsdb_sdk.utils.objects_collection.CollectionBase- 
create(name: str, query_str: str = None, start_at: datetime.datetime = None, end_at: datetime.datetime = None, repeat_str: str = None, repeat_min: int = None) → Optional[mindsdb_sdk.jobs.Job]¶
- Create new job in project and return it. - If it is not possible (job executed and not accessible anymore):
- return None 
 - Usage options: - Option 1: to use string query All job tasks could be passed as string with sql queries. Job is created immediately - >>> job = con.jobs.create('j1', query_str='retrain m1; show models', repeat_min=1): - Option 2: to use ‘with’ block. It allows to pass sdk commands to job tasks. Not all sdk commands could be accepted here, - only those which are converted in to sql in sdk and sent to /query endpoint - Adding query sql string is accepted as well Job will be created after exit from ‘with’ block - >>> with con.jobs.create('j1', repeat_min=1) as job: >>> job.add_query(table1.insert(table2)) >>> job.add_query('retrain m1') # using string - More info about jobs: https://docs.mindsdb.com/sql/create/jobs - Parameters
- name – name of the job 
- query_str – str, job’s query (or list of queries with ‘;’ delimiter) which job have to execute 
- start_at – datetime, first start of job, 
- end_at – datetime, when job have to be stopped, 
- repeat_str – str, optional, how to repeat job (e.g. ‘1 hour’, ‘2 weeks’, ‘3 min’) 
- repeat_min – int, optional, period to repeat the job in minutes 
 
- Returns
- Job object or None 
 
 - 
drop(name: str)¶
- Drop job from project - Parameters
- name – name of the job 
 
 - 
get(name: str) → mindsdb_sdk.jobs.Job¶
- Get job by name from project - Parameters
- name – name of the job 
- Returns
- Job object 
 
 - 
list() → List[mindsdb_sdk.jobs.Job]¶
- Show list of jobs in project - Returns
- list of Job objects 
 
 
-