pymensago/contactdb.py
def load_field(db: sqlite3.Connection, id: UUID, fieldname: str) -> RetVal:
	'''Loads a field from the database. Fieldname is expected to be in dot-separated format. If the 
	fieldname is an asterisk (*), all fields are loaded and value is a list, not a string'''

	if not id.is_valid() or not fieldname or not db:
		return RetVal(ErrBadValue)
	
	cursor = db.cursor()
	if fieldname == '*':
		cursor.execute('''SELECT fieldname,fieldvalue,contactgroup FROM contactinfo''')
		results = cursor.fetchall()
		if not results or not results[0][0]:
			return RetVal(ErrNotFound)
		
		outnames = list()
		outvalues = list()
		outgroups = list()
		for result in results:
			outnames.append(result[0])
			outvalues.append(result[1])
			outgroups.append(result[2])
		return RetVal().set_values({'name':outnames, 'value':outvalues, 'group':outgroups})
	else:
		cursor.execute(
			'''SELECT fieldvalue,contactgroup FROM contactinfo WHERE id=? AND fieldname=?''',
			(id.as_string(),fieldname))
		results = cursor.fetchone()
		if not results or not results[0]:
			return RetVal(ErrNotFound)

	return RetVal().set_values({ 'value':results[0], 'group':results[1] })
Loads a field from the database. Fieldname is expected to be in dot-separated format. If the 
	fieldname is an asterisk (*), all fields are loaded and value is a list, not a string
Loads a field from the database. Fieldname is expected to be in dot-separated format. If the
fieldname is an asterisk (*), all fields are loaded and value is a list, not a string
Loads a field from the database . Fieldname is expected to be in dot - separated format . If the fieldname is an asterisk ( * ) all fields are loaded and value is a list not a string
def load_field(db: sqlite3.Connection, id: UUID, fieldname: str) -> RetVal:
	if not id.is_valid() or not fieldname or not db:
		return RetVal(ErrBadValue)
	cursor = db.cursor()
	if fieldname == '*':
		cursor.execute('''SELECT fieldname,fieldvalue,contactgroup FROM contactinfo''')
		results = cursor.fetchall()
		if not results or not results[0][0]:
			return RetVal(ErrNotFound)
		outnames = list()
		outvalues = list()
		outgroups = list()
		for result in results:
			outnames.append(result[0])
			outvalues.append(result[1])
			outgroups.append(result[2])
		return RetVal().set_values({'name':outnames, 'value':outvalues, 'group':outgroups})
	else:
		cursor.execute(
			'''SELECT fieldvalue,contactgroup FROM contactinfo WHERE id=? AND fieldname=?''',
			(id.as_string(),fieldname))
		results = cursor.fetchone()
		if not results or not results[0]:
			return RetVal(ErrNotFound)
	return RetVal().set_values({ 'value':results[0], 'group':results[1] })
def load_field ( db : sqlite3 . Connection , id : UUID , fieldname : str ) -> RetVal : if not id . is_valid ( ) or not fieldname or not db : return RetVal ( ErrBadValue ) cursor = db . cursor ( ) if fieldname == '*' : cursor . execute ( '''SELECT fieldname,fieldvalue,contactgroup FROM contactinfo''' ) results = cursor . fetchall ( ) if not results or not results [ 0 ] [ 0 ] : return RetVal ( ErrNotFound ) outnames = list ( ) outvalues = list ( ) outgroups = list ( ) for result in results : outnames . append ( result [ 0 ] ) outvalues . append ( result [ 1 ] ) outgroups . append ( result [ 2 ] ) return RetVal ( ) . set_values ( { 'name' : outnames , 'value' : outvalues , 'group' : outgroups } ) else : cursor . execute ( '''SELECT fieldvalue,contactgroup FROM contactinfo WHERE id=? AND fieldname=?''' , ( id . as_string ( ) , fieldname ) ) results = cursor . fetchone ( ) if not results or not results [ 0 ] : return RetVal ( ErrNotFound ) return RetVal ( ) . set_values ( { 'value' : results [ 0 ] , 'group' : results [ 1 ] } )
Loads a field from the database.
Loads a field from the database .
'''Loads a field from the database. Fieldname is expected to be in dot-separated format. If the 
	fieldname is an asterisk (*), all fields are loaded and value is a list, not a string'''
db
sqlite3.Connection
id
UUID
fieldname
str