def create_job(db, datadir):
    """
    Create job for the given user, return it.

    :param db:
        a :class:`openquake.server.dbapi.Db` instance
    :param datadir:
        Data directory of the user who owns/started this job.
    :returns:
        the job ID
    """
    calc_id = get_calc_id(db, datadir) + 1
    job = dict(id=calc_id, is_running=1, description='just created',
               user_name='openquake', calculation_mode='to be set',
               ds_calc_dir=os.path.join('%s/calc_%s' % (datadir, calc_id)))
    return db('INSERT INTO job (?S) VALUES (?X)',
              job.keys(), job.values()).lastrowid
Create job for the given user, return it.

    :param db:
        a :class:`openquake.server.dbapi.Db` instance
    :param datadir:
        Data directory of the user who owns/started this job.
    :returns:
        the job ID