This was something I did quite long ago when I first started playing
with ViewVC and Subversion. See... my SVN repository contains info in
foreign languages; specifically, Japanese. MySQL wasn't happy with the
default table collations being in us-ascii, so I touched up both the
table creations and the DB connection to ensure that things were going
back and forth in UTF8.
Index: lib/cvsdb.py
===================================================================
--- lib/cvsdb.py (revision 1372)
+++ lib/cvsdb.py (working copy)
@@ -51,6 +51,13 @@
self.db = dbi.connect(
self._host, self._port, self._user, self._passwd,
self._database)
+ cursor = self.db.cursor()
+
+ sql = "SET NAMES utf8"
+ cursor.execute(sql)
+
+ cursor = self.db.cursor()
+
def sql_get_id(self, table, column, value, auto_set):
sql = "SELECT id FROM %s WHERE %s=%%s" % (table, column)
sql_args = (value, )
Index: bin/make-database
===================================================================
--- bin/make-database (revision 1372)
+++ bin/make-database (working copy)
@@ -39,7 +39,7 @@
branch varchar(64) binary DEFAULT '' NOT NULL,
PRIMARY KEY (id),
UNIQUE branch (branch)
-);
+) CHARSET=utf8;
DROP TABLE IF EXISTS checkins;
CREATE TABLE checkins (
@@ -62,7 +62,7 @@
KEY dirid (dirid),
KEY fileid (fileid),
KEY branchid (branchid)
-);
+) CHARSET=utf8;
DROP TABLE IF EXISTS descs;
CREATE TABLE descs (
@@ -71,7 +71,7 @@
hash bigint(20) DEFAULT '0' NOT NULL,
PRIMARY KEY (id),
KEY hash (hash)
-);
+) CHARSET=utf8;
DROP TABLE IF EXISTS dirs;
CREATE TABLE dirs (
@@ -79,7 +79,7 @@
dir varchar(255) binary DEFAULT '' NOT NULL,
PRIMARY KEY (id),
UNIQUE dir (dir)
-);
+) CHARSET=utf8;
DROP TABLE IF EXISTS files;
CREATE TABLE files (
@@ -87,7 +87,7 @@
file varchar(255) binary DEFAULT '' NOT NULL,
PRIMARY KEY (id),
UNIQUE file (file)
-);
+) CHARSET=utf8;
DROP TABLE IF EXISTS people;
CREATE TABLE people (
@@ -95,7 +95,7 @@
who varchar(32) binary DEFAULT '' NOT NULL,
PRIMARY KEY (id),
UNIQUE who (who)
-);
+) CHARSET=utf8;
DROP TABLE IF EXISTS repositories;
CREATE TABLE repositories (
@@ -103,7 +103,7 @@
repository varchar(64) binary DEFAULT '' NOT NULL,
PRIMARY KEY (id),
UNIQUE repository (repository)
-);
+) CHARSET=utf8;
DROP TABLE IF EXISTS tags;
CREATE TABLE tags (
@@ -117,7 +117,7 @@
KEY dirid (dirid),
KEY fileid (fileid),
KEY branchid (branchid)
-);
+) CHARSET=utf8;
"""
if __name__ == "__main__":
|