Beispiel #1
0
def put(redcap_env, projectid, recordid, attrname, attrval):
    '''Put a new name-value pair into the store. It will create
  a new version if an older one already exists. Note: returns empty tuple.'''
    stmt = '''insert into eav (env, projectid, recordid, attrname, attrval)
            values (%s, %s, %s, %s, %s) '''
    vals = redcap_env, projectid, recordid, attrname, attrval
    rslt = db.go(db_spec, stmt, vals, commit=True)
    return rslt
Beispiel #2
0
def exists(redcap_env, projectid, recordid, attrname):
    qy1 = '''select count(*) as ttl
          from eav
          where env = %s and projectid = %s
            and recordid = %s
            and attrname = %s	'''
    vals = redcap_env, projectid, recordid, attrname
    ttl = db.go(db_spec, qy1, vals, db.ReturnKind.SINGLEVAL)
    if ttl > 0: return True
    else: return False
Beispiel #3
0
def get_latest_value(redcap_env, projectid, recordid, attrname):
    '''Will return empty string if it can't find anything.'''
    qy2 = '''select ifnull(attrval, 'nil') as attrval
          from eav
          where env = %s and projectid = %s
            and recordid = %s
            and attrname = %s
          order by ts DESC -- put latest value in first row '''
    vals = redcap_env, projectid, recordid, attrname
    # Grab the first value in the first row
    rslt = db.go(db_spec, qy2, vals, db.ReturnKind.SINGLEVAL)
    return rslt