From f3783dc307c26cfd0d9b221ec9440881360ed7c0 Mon Sep 17 00:00:00 2001 From: Andrew Davidson Date: Wed, 29 Feb 2012 21:39:30 -0800 Subject: [PATCH] insert only if it doesnt already exist --- mysecrets.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mysecrets.py b/mysecrets.py index 89edff5..bf35880 100755 --- a/mysecrets.py +++ b/mysecrets.py @@ -94,8 +94,13 @@ class index: if method == 'create': i = web.input() - n = db.insert('passwords', username=i.username, password=i.password, \ - base_url=i.base_url) + + exists = db.select('passwords', where='username="'+i.username+'" and password="' +\ + i.password+'" and base_url="'+i.base_url+'"') + + if not exists: + n = db.insert('passwords', username=i.username, password=i.password, \ + base_url=i.base_url) selected = get_pair_from_url(i.base_url)