Archive for November, 2006

Importing UTF-8 encoded CSV files into MySQL

Sunday, November 26th, 2006

In MySQL you can use the LOAD DATA INFILE syntax to import so-called CSV fiiles into one of your database tables. I recently needed to do this to import data from Microsoft Access.

Because there were several French accent signs and other strange characters in the database, I chose UTF-8 encoding for both the CSV file and the target table in MySQL.

The problem was, that this method did not work. All my special characters were corrupted. The solution finally was to set the character_set_database environment variable of MySQL to UTF-8 before executing the query:

  1. SET character_set_database=utf8;
  2. LOAD DATA LOCAL INFILE '/tmp/somefile.txt' REPLACE INTO TABLE tmpsomefiletable
  3. FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '"';
  4. SET character_set_database=default;

The last SQL statement resets the environment value back to the default one. It is – of course – optional.

Don’t lock your users in!

Wednesday, November 22nd, 2006

A note to software developers and software company managers: Don’t lock your users into a specific system. They might switch to a better application:

From the perspective of a help desk technician, [...] I want to be able to access the system from anywhere. This is one of the key advantages of a web-based interface. With Track-It (my previous system), you had to install a “technician client” on each technician’s computer. They have a web interface but it uses ActiveX controls that cause it to only work on Windows, and then, only on Internet Explorer. So, good luck if you are running a Mac or you really like Firefox.

Kiere in a weblog post about help desk applications. Via Joel. Emphasis mine.

Remove old Debian packages

Saturday, November 11th, 2006

As your Debian/Ubuntu system gets older, there might be a number of packages lying around on your hard disk, that you no longer need. These packages are called orphaned packages. Usually they contain libraries, that were required by another software package you installed. Maybe the software package was replaced by a new package, that dropped the dependency on that library (version). Or you removed the software package entirely, because you no longer needed it.

These orphaned packages are not used by any other packages and are therefore taking up useless space. You can remove them with deborphan.

If deborphan is not already installed on your system, install it.

  1. sudo apt-get install deborphan

Now you can use the following combination of commands to automatically remove all software packages, that are found by deborphan.

  1. sudo deborphan | xargs sudo apt-get remove --purge

The latter should be done regularly to keep the number of redundant packages at a minimum.

Mozilla Talkback error on Linux

Friday, November 3rd, 2006

On Linux systems, Mozilla Firefox or Mozilla Thunderbird are used by normal users without root privileges most of the time. Unfortunately, this has some odd side effects. For example, it is not possible to upgrade the browser via the help menu as a normal user. Also, if you launch the applications from the command line, you might get the following error message:

  1. (QFA)Talkback error: Can't initialize.

There are two solutions for this problem. The first solution would be to always launch the Mozilla applications with root privileges. Of course this is only possible, if you know the root password and it also poses a huge security risk. Another solution is to disable Talkback altogether. Most Linux distributions do this for their packages by default. But if you use an official build distributed directly by the Mozilla Foundation, you need to do this yourself.

To do so go to the directory of your Mozilla application. This will be the directory where the binary files of the application are located. In the sub folder extensions, you will find a folder called talkback@mozilla.org. Remove this folder and you’re done. The error message should be gone.

In the mid-term, Talkback will be replaced by an open source solution developed jointly by the Mozilla Foundation and Google. Let’s hope that this solution is a bit more Linux-friendly.