Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/store.py
diff options
context:
space:
mode:
authorflavio <fdanesse@gmail.com>2012-04-25 14:18:29 (GMT)
committer flavio <fdanesse@gmail.com>2012-04-25 14:18:29 (GMT)
commit40c72c67b36bd80a4dd936a8bc889526dd62b2af (patch)
tree1382e02285863833dce1eb916b57377107d24d68 /store.py
parentef0afced91216be8953a7ee05516c4d1f729d82f (diff)
Correcciones y Agrego Eliminar Registro
Diffstat (limited to 'store.py')
-rw-r--r--store.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/store.py b/store.py
index 76b486c..6075c4e 100644
--- a/store.py
+++ b/store.py
@@ -15,11 +15,18 @@ import shelve
# for future releases
#from xml.dom import minidom
+init_db = """
+CREATE TABLE IF NOT EXISTS notifications (id INTEGER PRIMARY KEY,
+title VARCHAR(30) NOT NULL ON CONFLICT REPLACE DEFAULT '',
+text TEXT NOT NULL ON CONFLICT REPLACE DEFAULT '',
+priority INTEGER NOT NULL,
+launched DATE NOT NULL ON CONFLICT REPLACE DEFAULT 00000000,
+expires DATETIME,
+type VARCHAR(15) NOT NULL ON CONFLICT REPLACE DEFAULT '',
+fav INTEGER NOT NULL ON CONFLICT REPLACE DEFAULT 0 ); """
class Db:
def __init__(self, db_filename=None):
- init_db = """
-CREATE TABLE IF NOT EXISTS notifications (id INTEGER PRIMARY KEY,title VARCHAR(30) NOT NULL ON CONFLICT REPLACE DEFAULT '',text TEXT NOT NULL ON CONFLICT REPLACE DEFAULT '', priority INTEGER NOT NULL, launched DATE NOT NULL ON CONFLICT REPLACE DEFAULT 00000000,expires DATETIME, type VARCHAR(15) NOT NULL ON CONFLICT REPLACE DEFAULT '',fav INTEGER NOT NULL ON CONFLICT REPLACE DEFAULT 0 ); """
if db_filename:
self._db_filename = db_filename
else:
@@ -61,7 +68,7 @@ CREATE TABLE IF NOT EXISTS notifications (id INTEGER PRIMARY KEY,title VARCHAR(3
c = con.cursor()
c.execute('BEGIN TRANSACTION')
try:
- c.execute('delete from notifications where id=%i' % id)
+ c.execute('delete from notifications where id=%i' % id_msg)
except sqlite3.IntegrityError, e:
print "Error al eliminar datos: %s" % str(e)
c.execute('END TRANSACTION')
@@ -74,7 +81,7 @@ CREATE TABLE IF NOT EXISTS notifications (id INTEGER PRIMARY KEY,title VARCHAR(3
c = con.cursor()
c.execute('BEGIN TRANSACTION')
try:
- c.execute('update notifications set fav=%i where id=%i' % (int(fav), id))
+ c.execute('update notifications set fav=%i where id=%i' % (int(fav), id_msg))
except sqlite3.IntegrityError, e:
print "Error al eliminar datos: %s" % str(e)
c.execute('END TRANSACTION')
@@ -130,9 +137,7 @@ CREATE TABLE IF NOT EXISTS notifications (id INTEGER PRIMARY KEY,title VARCHAR(3
return output
"""
-
class Store:
-
def __init__(self, xmlpath=None, db_filename=None):
self.db = Db(db_filename)
# Borro todas las notificaciones que ya expiraron