# HG changeset patch # User Daniele Nicolodi # Date 1309201524 -7200 # Node ID 75de027b49e700ab76a9a5f3a308dd34d1cab794 # Parent 56e3649ff013b63fff051f452fe65ebc06b87645 Always use utf8 charset for database connections. diff -r 56e3649ff013 -r 75de027b49e7 src/ltpdarepo/admin.py --- a/src/ltpdarepo/admin.py Mon Jun 27 21:05:24 2011 +0200 +++ b/src/ltpdarepo/admin.py Mon Jun 27 21:05:24 2011 +0200 @@ -134,7 +134,7 @@ def grant(username, database, privs): """grant permissions to given user for a specific database""" - conn = mysql.connect(host=HOSTNAME, db=DATABASE, user=USERNAME, passwd=PASSWORD) + conn = mysql.connect(host=HOSTNAME, db=DATABASE, user=USERNAME, passwd=PASSWORD, charset='utf8') curs = conn.cursor() if 'admin' in privs: @@ -157,7 +157,7 @@ def privileges(username): """show privileges for given user""" - conn = mysql.connect(host=HOSTNAME, db=DATABASE, user=USERNAME, passwd=PASSWORD) + conn = mysql.connect(host=HOSTNAME, db=DATABASE, user=USERNAME, passwd=PASSWORD, charset='utf8') curs = conn.cursor() privs = {} @@ -207,7 +207,7 @@ def wipe(yes=True): """delete all database content""" - conn = mysql.connect(host=HOSTNAME, db='', user=USERNAME, passwd=PASSWORD) + conn = mysql.connect(host=HOSTNAME, db='', user=USERNAME, passwd=PASSWORD, charset='utf8') curs = conn.cursor() # databases list @@ -239,7 +239,7 @@ def populate(database, nobjs): """populate a dababase witn fake objects""" - conn = mysql.connect(host=HOSTNAME, db=database, user=USERNAME, passwd=PASSWORD) + conn = mysql.connect(host=HOSTNAME, db=database, user=USERNAME, passwd=PASSWORD, charset='utf8') curs = conn.cursor() from datetime import datetime diff -r 56e3649ff013 -r 75de027b49e7 src/ltpdarepo/install.py --- a/src/ltpdarepo/install.py Mon Jun 27 21:05:24 2011 +0200 +++ b/src/ltpdarepo/install.py Mon Jun 27 21:05:24 2011 +0200 @@ -6,13 +6,13 @@ def install(): """create LTDA repository database tables""" - conn = mysql.connect(host=HOSTNAME, db='', user=USERNAME, passwd=PASSWORD) + conn = mysql.connect(host=HOSTNAME, db='', user=USERNAME, passwd=PASSWORD, charset='utf8') curs = conn.cursor() curs.execute("CREATE DATABASE `%s`" % DATABASE) conn.close() - conn = mysql.connect(host=HOSTNAME, db=DATABASE, user=USERNAME, passwd=PASSWORD) + conn = mysql.connect(host=HOSTNAME, db=DATABASE, user=USERNAME, passwd=PASSWORD, charset='utf8') curs = conn.cursor() curs.execute("""CREATE TABLE `available_dbs` ( diff -r 56e3649ff013 -r 75de027b49e7 src/ltpdarepo/tests/test_users.py --- a/src/ltpdarepo/tests/test_users.py Mon Jun 27 21:05:24 2011 +0200 +++ b/src/ltpdarepo/tests/test_users.py Mon Jun 27 21:05:24 2011 +0200 @@ -70,14 +70,16 @@ u2.create() # test that the user can connect to the database conn = mysql.connect(host=self.app.config['HOSTNAME'], - user=u2.username, passwd=u2.password) + user=u2.username, passwd=u2.password, + charset='utf8') def test_user_login_generated_password(self): u2 = User(username='u2') u2.create() # test that the user can connect to the database conn = mysql.connect(host=self.app.config['HOSTNAME'], - user=u2.username, passwd=u2.password) + user=u2.username, passwd=u2.password, + charset='utf8') if __name__ == '__main__': diff -r 56e3649ff013 -r 75de027b49e7 src/ltpdarepo/upgrade.py --- a/src/ltpdarepo/upgrade.py Mon Jun 27 21:05:24 2011 +0200 +++ b/src/ltpdarepo/upgrade.py Mon Jun 27 21:05:24 2011 +0200 @@ -20,7 +20,7 @@ def upgrade(fromrev=None): """run database schema upgrade steps""" - conn = mysql.connect(host=HOSTNAME, db=DATABASE, user=USERNAME, passwd=PASSWORD) + conn = mysql.connect(host=HOSTNAME, db=DATABASE, user=USERNAME, passwd=PASSWORD, charset='utf8') curs = conn.cursor() logger = logging.getLogger(__name__)