[yum-cvs] yum/yum sqlitesack.py,1.40,1.41
Seth Vidal
skvidal at linux.duke.edu
Tue Aug 29 05:17:56 UTC 2006
Update of /home/groups/yum/cvs/yum/yum
In directory login1.linux.duke.edu:/tmp/cvs-serv24302/yum
Modified Files:
sqlitesack.py
Log Message:
fix up YumAvailablePackageSqlite.returnSimple()
- if you select %s and pass it in on the cursor.execute with sqlite you end
up with a quoted string. So "select %s from foo", ('somevar')
results in this:
select 'somevar' from foo
which means EVERY answer you get back will be 'somevar' and not the value in
the row for that column.
If anyone knows how to turn off that quoting per-variable in sqlite, let me
know - the docs didn't have it.
We also needed an simple-dict to db column-name map so querying for certain
things would return the right information.
Index: sqlitesack.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/sqlitesack.py,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- sqlitesack.py 27 Aug 2006 20:07:25 -0000 1.40
+++ sqlitesack.py 29 Aug 2006 05:17:54 -0000 1.41
@@ -41,14 +41,35 @@
self.files = None
def returnSimple(self, varname):
+ db2simplemap = { 'packagesize' : 'size_package',
+ 'archivesize' : 'size_archive',
+ 'installedsize' : 'size_installed',
+ 'buildtime' : 'time_build',
+ 'hdrstart' : 'rpm_header_start',
+ 'hdrend' : 'rpm_header_end',
+ 'basepath' : 'location_base',
+ 'relativepath': 'location_href',
+ 'filetime' : 'time_file',
+ 'packager' : 'rpm_packager',
+ 'group' : 'rpm_group',
+ 'buildhost' : 'rpm_buildhost',
+ 'sourcerpm' : 'rpm_sourcerpm',
+ 'vendor' : 'rpm_vendor',
+ 'license', : 'rpm_license'
+ }
if not self.simple.has_key(varname):
+ dbname = varname
+ if db2simplemap.has_key(varname):
+ dbname = db2simplemap[varname]
cache = self.sack.primarydb[self.repoid]
c = cache.cursor()
- c.execute("select %s from packages where pkgId = %s",
- varname, self.pkgId)
+ query = "select %s from packages where pkgId = '%s'" % (dbname, self.pkgId)
+ #c.execute("select %s from packages where pkgId = %s",
+ # dbname, self.pkgId)
+ c.execute(query)
r = c.fetchone()
self.simple[varname] = r[0]
-
+
return YumAvailablePackage.returnSimple(self,varname)
def _loadFiles(self):
More information about the Yum-cvs-commits
mailing list