Skip to content
Browse files

Clean up this database function a little bit

  • Loading branch information...
1 parent 94a29ff commit 11b5843029e09694fe4911990272feac6961ad63 @dstufft committed Feb 27, 2014
Showing with 8 additions and 7 deletions.
  1. +8 −7 warehouse/packaging/models.py
View
15 warehouse/packaging/models.py
@@ -409,16 +409,17 @@ def _make_key(precision, datetime, key):
)
def get_classifier_ids(self, classifiers):
- placeholders = ', '.join(['%s'] * len(classifiers))
query = \
- """SELECT classifier, id
- FROM trove_classifiers
- WHERE classifier IN (%s)
- """ % placeholders
+ """ SELECT classifier, id
+ FROM trove_classifiers
+ WHERE classifier IN %(classifiers)s
+ """
with self.engine.connect() as conn:
- return dict((r['classifier'], r['id'])
- for r in conn.execute(query, *classifiers))
+ return {
+ r["classifier"]: r["id"]
+ for r in conn.execute(query, classifiers=tuple(classifiers))
+ }
def search_by_classifier(self, selected_classifiers):
# Note: selected_classifiers is a list of ids from trove_classifiers

0 comments on commit 11b5843

Please sign in to comment.
Something went wrong with that request. Please try again.