Example #1
0
File: sqlite.py Project: vijo/sqink
 def add(self, note):
     uuid= note.uuid
     params= (uuid, note.lastModified, note.createdOn, note.title, self.__flatten(note.tags), 1 if note.starred else 0,
             note.text, note.html)
     with self.__connection:
         self.__connection.execute("DELETE FROM Note WHERE uuid = ? AND active = 0;", (uuid,))
         self.__connection.execute("INSERT INTO Note VALUES (?, ?, 1, ?, ?, ?, ?, ?, ?);", params)
     savePhoto(note, self.__photoPath(uuid))
Example #2
0
 def add(self, note):
     uuid = note.uuid
     tags = self.__flatten(note.tags)
     starred = 1 if note.starred else 0
     params = (uuid, note.lastModified, note.createdOn, note.title, tags,
               starred, note.text, note.html)
     with self.__connection:
         self.__connection.execute(
             "DELETE FROM Note WHERE uuid = ? AND active = 0;", (uuid, ))
         self.__connection.execute(
             "INSERT INTO Note VALUES (?, ?, 1, ?, ?, ?, ?, ?, ?);", params)
     savePhoto(note, self.__photoPath(uuid))
Example #3
0
File: sqlite.py Project: vijo/sqink
    def update(self, note):
        uuid= note.uuid
        query= "UPDATE Note SET lastModified = ?, createdOn = ?, title = ?, tags = ?, starred = ?, text = ?, html = ? " +\
                "WHERE uuid = ? AND active = 1;"
        params= (note.lastModified, note.createdOn, note.title, self.__flatten(note.tags), 1 if note.starred else 0,
                note.text, note.html, uuid)
        cursor= self.__connection.cursor()
        cursor.execute(query, params)
        if cursor.rowcount != 1:
            self.__connection.rollback()
            raise RuntimeError("Note[uuid=%s] does not exist" % uuid)
        self.__connection.commit()

        photoPath= self.__photoPath(uuid)
        savePhoto(note, photoPath)
Example #4
0
    def update(self, note):
        uuid = note.uuid
        tags = self.__flatten(note.tags)
        starred = 1 if note.starred else 0
        query = "UPDATE Note SET lastModified = ?, createdOn = ?, title = ?, tags = ?, starred = ?, text = ?, " +\
                "html = ? WHERE uuid = ? AND active = 1;"
        params = (note.lastModified, note.createdOn, note.title, tags, starred,
                  note.text, note.html, uuid)
        cursor = self.__connection.cursor()
        cursor.execute(query, params)
        if cursor.rowcount != 1:
            self.__connection.rollback()
            raise RuntimeError("Note[uuid=%s] does not exist" % uuid)
        self.__connection.commit()

        photoPath = self.__photoPath(uuid)
        savePhoto(note, photoPath)