logo       


UTF8 MySQL/cvsdb patch: msg#00003

Subject: UTF8 MySQL/cvsdb patch
    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__":


Ruby Jobs
Java Jobs
Jobs in California
more...
what
job title, keywords
where
city, state, zip
jobs by job search
Search:
Java, servers, webhosting, windows, cisco ...
more...
<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
encryption.gpg....    ietf.rfc822/199...    freebsd.devel.i...    lang.haskell.li...    mail.squirrelma...    web.zope.plone....    yellowdog.gener...    text.xml.xalan....    recreation.phot...    kde.devel.educa...    hardware.bus.ca...    printing.ghosts...    voip.peering/20...    assembly/2006-0...    org.user-groups...    culture.interne...    network.i2p/200...    boot-loaders.ya...    xfree86.render/...    qnx.openqnx.dev...    jakarta.velocit...    user-groups.pal...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe