"""
cursor = DBConn().cursor();
cursor.execute( "BEGIN WORK" )
- cursor.execute( remove_pending_contents_cruft_q )
- cursor.execute( remove_filename_cruft_q )
- cursor.execute( remove_filepath_cruft_q )
+ DBConn().prepare("remove_pending_contents_cruft_q", remove_pending_contents_cruft_q)
+ DBConn().prepare("remove_filename_cruft_q", remove_filename_cruft_q)
+ DBConn().prepare("remove_filepath_cruft_q", remove_filepath_cruft_q)
cursor.execute( "COMMIT" )
pooldir = Config()[ 'Dir::Pool' ]
cursor = DBConn().cursor();
- cursor.execute( debs_q )
- cursor.execute( olddeb_q )
- cursor.execute( arches_q )
+ DBConn().prepare("debs_q",debs_q)
+ DBConn().prepare("olddeb_q",olddeb_q)
+ DBConn().prepare("arches_q",arches_q)
suites = self._suites()
for suite in [i.lower() for i in suites]:
"""
cursor = DBConn().cursor();
- cursor.execute( arches_q )
- cursor.execute( contents_q )
- cursor.execute( udeb_contents_q )
+ DBConn().prepare( "arches_q", arches_q )
+ DBConn().prepare( "contents_q", contents_q )
+ DBConn().prepare( "udeb_contents_q", udeb_contents_q )
debtype_id=DBConn().get_override_type_id("deb")
udebtype_id=DBConn().get_override_type_id("udeb")
cursor = DBConn().cursor()
# Check for packages that have moved from one component to another
# STU: this should probably be changed to not join on architecture, suite tables but instead to used their cached name->id mappings from DBConn
- cursor.execute("""PREPARE moved_pkg_q(text,text,text) AS
+ DBConn().prepare("moved_pkg_q", """
+ PREPARE moved_pkg_q(text,text,text) AS
SELECT c.name FROM binaries b, bin_associations ba, suite s, location l,
component c, architecture a, files f
WHERE b.package = $1 AND s.suite_name = $2
'suite_version': Cache(lambda x: '%s_%s' % (x['source'], x['suite'])),
}
+ self.prepared_statements = {}
+
+ def prepare(self,name,statement):
+ if not self.prepared_statements.has_key(name):
+ c = self.cursor()
+ c.execute(statement)
+ self.prepared_statements[name] = statement
+
def clear_caches(self):
self.__init_caches()