- def setRecord(self, rid, content = None, label = None):
- """
- Alter an existing record
- """
- if content:
- self.dbcur.execute('UPDATE notes SET content = "' + self.escape(content) +
- '" WHERE id = ' + str(rid) + ';')
- if label:
- self.dbcur.execute('UPDATE notes SET label = "' + self.escape(label) +
- '" WHERE id = ' + str(rid) + ';')
-
- def addRecord(self, label = '', content = ''):
- """
- Create a new record, return the new record id
- """
- self.dbcur.execute('INSERT INTO notes (label, content) VALUES ("' + self.escape(label) +
- '", "' + self.escape(content) + '");')
+ def setRecord(self, rid = None, label = None, content = None):
+ """
+ Create or alter a record
+ """
+ if not rid:
+ if label: label = self.escape(label)
+ else: label = ''
+ if content: content = self.escape(content)
+ else: content = ''
+ self.dbcur.execute('INSERT INTO notes (label, content) VALUES ("' + self.escape(label) +
+ '", "' + self.escape(content) + '");')
+ else:
+ if content:
+ self.dbcur.execute('UPDATE notes SET content = "' + self.escape(content) +
+ '" WHERE id = ' + str(rid) + ';')
+ if label:
+ self.dbcur.execute('UPDATE notes SET label = "' + self.escape(label) +
+ '" WHERE id = ' + str(rid) + ';')