pymensago/keycard.py
def db_get_card(db: sqlite3.Connection, owner: str) -> RetVal:
	'''Obtains the entire keycard for the requested owner from the database'''
	cursor = db.cursor()
	cursor.execute("SELECT type,entry FROM keycards WHERE owner=? ORDER BY 'index'",
		(owner,))
	results = cursor.fetchone()
	if not results or not results[0] or not results[1]:
		return RetVal(ErrNotFound)
	
	if results[0].casefold() == 'organization':
		entry = OrgEntry()
	elif results[0].casefold() == 'user':
		entry = UserEntry()
	else:
		return RetVal(ErrBadType, f"bad entry type '{results[0]}' found in database")

	card = Keycard(entry.type)
	while results:
		status = entry.set(results[1])
		if status.error():
			return status
		card.entries.append(entry)
		results = cursor.fetchone()

	return RetVal().set_value('card', card)
Obtains the entire keycard for the requested owner from the database
Obtains the entire keycard for the requested owner from the database
Obtains the entire keycard for the requested owner from the database
def db_get_card(db: sqlite3.Connection, owner: str) -> RetVal:
	cursor = db.cursor()
	cursor.execute("SELECT type,entry FROM keycards WHERE owner=? ORDER BY 'index'",
		(owner,))
	results = cursor.fetchone()
	if not results or not results[0] or not results[1]:
		return RetVal(ErrNotFound)
	if results[0].casefold() == 'organization':
		entry = OrgEntry()
	elif results[0].casefold() == 'user':
		entry = UserEntry()
	else:
		return RetVal(ErrBadType, f"bad entry type '{results[0]}' found in database")
	card = Keycard(entry.type)
	while results:
		status = entry.set(results[1])
		if status.error():
			return status
		card.entries.append(entry)
		results = cursor.fetchone()
	return RetVal().set_value('card', card)
def db_get_card ( db : sqlite3 . Connection , owner : str ) -> RetVal : cursor = db . cursor ( ) cursor . execute ( "SELECT type,entry FROM keycards WHERE owner=? ORDER BY 'index'" , ( owner , ) ) results = cursor . fetchone ( ) if not results or not results [ 0 ] or not results [ 1 ] : return RetVal ( ErrNotFound ) if results [ 0 ] . casefold ( ) == 'organization' : entry = OrgEntry ( ) elif results [ 0 ] . casefold ( ) == 'user' : entry = UserEntry ( ) else : return RetVal ( ErrBadType , f"bad entry type '{results[0]}' found in database" ) card = Keycard ( entry . type ) while results : status = entry . set ( results [ 1 ] ) if status . error ( ) : return status card . entries . append ( entry ) results = cursor . fetchone ( ) return RetVal ( ) . set_value ( 'card' , card )
Obtains the entire keycard for the requested owner from the database
Obtains the entire keycard for the requested owner from the database
'''Obtains the entire keycard for the requested owner from the database'''
db
sqlite3.Connection
owner
str