pymensago/keycard.py
def db_get_last_entry(self, db: sqlite3.Connection, owner: str) -> RetVal:
	'''Gets the most recent entry from the database'''
	
	cursor = db.cursor()
	cursor.execute("SELECT type,entry FROM keycards WHERE owner=? ORDER BY 'index' DESC LIMIT 1",
		(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")

	status = entry.set(results[1])
	if status.error():
		return status
	return RetVal().set_value('entry', entry)
Gets the most recent entry from the database
Gets the most recent entry from the database
Gets the most recent entry from the database
def db_get_last_entry(self, db: sqlite3.Connection, owner: str) -> RetVal:
	cursor = db.cursor()
	cursor.execute("SELECT type,entry FROM keycards WHERE owner=? ORDER BY 'index' DESC LIMIT 1",
		(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")
	status = entry.set(results[1])
	if status.error():
		return status
	return RetVal().set_value('entry', entry)
def db_get_last_entry ( self , db : sqlite3 . Connection , owner : str ) -> RetVal : cursor = db . cursor ( ) cursor . execute ( "SELECT type,entry FROM keycards WHERE owner=? ORDER BY 'index' DESC LIMIT 1" , ( 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" ) status = entry . set ( results [ 1 ] ) if status . error ( ) : return status return RetVal ( ) . set_value ( 'entry' , entry )
Gets the most recent entry from the database
Gets the most recent entry from the database
'''Gets the most recent entry from the database'''
self
db
sqlite3.Connection
owner
str