#
# TODO: Use existing PLC database methods? or keep this separate?
-import report
import pgdb
from sfa.util.PostgreSQL import *
from sfa.trust.gid import *
from sfa.util.record import *
-from sfa.util.debug import *
from sfa.util.config import *
from sfa.util.filter import *
if record_filter:
records = self.find(record_filter)
- for record in reocrds:
+ for record in records:
self.append(record)
def exists(self):
for index in indexes:
self.db.do(index)
- sefl.db.commit()
+ self.db.commit()
def remove(self, record):
- query_str = "DELETE FROM %s WHERE record_id = %s" % \
- (self.tablename, record['record_id'])
- self.db.do(query_str)
+ params = {'record_id': record['record_id']}
+ template = "DELETE FROM %s " % self.tablename
+ sql = template + "WHERE record_id = %(record_id)s"
+ self.db.do(sql, params)
# if this is a site, remove all records where 'authority' == the
# site's hrn
if record['type'] == 'authority':
- sql = " DELETE FROM %s WHERE authority = %s" % \
- (self.tablename, record['hrn'])
- self.db.do(sql)
- self.db.commit()
+ params = {'authority': record['hrn']}
+ sql = template + "WHERE authority = %(authority)s"
+ self.db.do(sql, params)
+ self.db.commit()
def insert(self, record):
db_fields = self.db_fields(record)
def drop(self):
try:
self.db.do('DROP TABLE IF EXISTS ' + self.tablename)
+ self.db.commit()
except:
try:
self.db.do('DROP TABLE ' + self.tablename)
+ self.db.commit()
except:
pass