pymensago/keycard.py
def db_add_entry(self, db: sqlite3.Connection, entry: EntryBase):
	'''Adds an entry to the database, ensuring no duplicates'''
	cursor = db.cursor()

	if entry.type == 'User':
		owner = f"{entry['Workspace-ID']}/{entry['Domain']}"
	else:
		owner = entry['Domain']
	cursor.execute("DELETE FROM keycards WHERE owner=? AND index=?", (owner,entry['Index']))

	entry_bytes = entry.make_bytestring(-1)
	cursor.execute('''
		INSERT INTO keycards(owner,index,type,entry,textentry,hash,expires,timestamp)
		VALUES(?,?,?,?,?,?,?,?)''',
		(owner, entry['Index'], entry.type, entry_bytes, str(entry_bytes), entry['Hash'], 
			entry['Expires'], entry['Timestamp']))
	db.commit()
Adds an entry to the database, ensuring no duplicates
Adds an entry to the database, ensuring no duplicates
Adds an entry to the database ensuring no duplicates
def db_add_entry(self, db: sqlite3.Connection, entry: EntryBase):
	cursor = db.cursor()
	if entry.type == 'User':
		owner = f"{entry['Workspace-ID']}/{entry['Domain']}"
	else:
		owner = entry['Domain']
	cursor.execute("DELETE FROM keycards WHERE owner=? AND index=?", (owner,entry['Index']))
	entry_bytes = entry.make_bytestring(-1)
	cursor.execute('''
		INSERT INTO keycards(owner,index,type,entry,textentry,hash,expires,timestamp)
		VALUES(?,?,?,?,?,?,?,?)''',
		(owner, entry['Index'], entry.type, entry_bytes, str(entry_bytes), entry['Hash'], 
			entry['Expires'], entry['Timestamp']))
	db.commit()
def db_add_entry ( self , db : sqlite3 . Connection , entry : EntryBase ) : cursor = db . cursor ( ) if entry . type == 'User' : owner = f"{entry['Workspace-ID']}/{entry['Domain']}" else : owner = entry [ 'Domain' ] cursor . execute ( "DELETE FROM keycards WHERE owner=? AND index=?" , ( owner , entry [ 'Index' ] ) ) entry_bytes = entry . make_bytestring ( - 1 ) cursor . execute ( '''
		INSERT INTO keycards(owner,index,type,entry,textentry,hash,expires,timestamp)
		VALUES(?,?,?,?,?,?,?,?)''' , ( owner , entry [ 'Index' ] , entry . type , entry_bytes , str ( entry_bytes ) , entry [ 'Hash' ] , entry [ 'Expires' ] , entry [ 'Timestamp' ] ) ) db . commit ( )
Adds an entry to the database, ensuring no duplicates
Adds an entry to the database ensuring no duplicates
'''Adds an entry to the database, ensuring no duplicates'''
self
db
sqlite3.Connection
entry
EntryBase