summaryrefslogtreecommitdiff
path: root/tools/utf8convert.py
blob: 19268d4f073be584248b312921ac110b2ff40500 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
''' Implements a store of disutils PKG-INFO entries, keyed off name, version.
'''
import sys, os, re, psycopg, time, sha, random, types, math, stat, errno
import logging

conn = psycopg.connect(database="pypi",
            user="pypi")

cursor = conn.cursor()
cursor.execute("SELECT * FROM releases")
for release in cursor.dictfetchall():
    newitem = {}
    for k,v in release.items():
        if type(v) is str:
            newitem[k]=v.decode("latin-1").encode('utf-8')
    cols = []
    values = []
    for k,v in newitem.items():
        cols.append("%s=%%s" % k)
        values.append(v)
    cols = ",".join(cols)
    values.append(newitem['name'])
    values.append(newitem['version'])
    stmt="update releases set %s where name=%%s and version=%%s" % cols
    cursor.execute(stmt, values)
conn.commit()