Posts Tagged ‘textbook’

Howto import a UTF8 textbook (book) in MySQL table / A simple step by step guide through on howto import books in MySQL

Tuesday, March 23rd, 2010

I was looking forward to import a textbook I own to MySQL in order to be able later to easily manipulate the text with MySQL queries. After some time spend on trying hard. Here is the steps I took to import the textbook:

1. First we create necessery database and set default charset to UTF8:

freebsd$ mysql -u root -p
# create database textbook in mysql and change it to your likings
mysql$ CREATE database "textbook";
mysql$ use textbook;
mysql$ SET NAMES UTF8;

2. Then we CREATE Necessery database that will use further as a table to import the textbook into:
Below we create the table “textbook” with one column “sentence”

mysql$ CREATE table textbook (sentence varchar(5000);

3. Now we import the book:

mysql$ LOAD DATA INFILE '/path/to/file/textbook.txt' INTO TABLE textbook;

4. Last it might be a good idea to add some extra numbered column to be able to track the lines of the textbook as below:

mysql$ ALTER table textbook ADD COLUMN ID INT NOT NULL auto_increment FIRST, ADD PRIMARY KEY(ID);

In my case the book was in cyrillic and after I’ve taken the above steps I didn’t have any problems with cyrillic letters in the table.
Of course the above method is a bit dump since it’s not flexible enough and doesn’t track the textbook parts or titles, however it’s still a good way to store example on how to store text data in mysql table and could help somebody further in his journey in learning MySQL and next to that serving some simple daily SQL taks.

The last few days

Wednesday, March 19th, 2008

Today Ivailo a relative called me and asked me to go to their second hand furniture shop and help them translating things to a English customers, Just after that we had Marketing Planning with a Dutch guy. After that I went to the VoIP to speak with the leaseweb’s salesdepartment because a friend of mine is thinking of colocation of few servers. Yesterday and today were a quiet days Thanks to The Lord. I have to create two projects one is about Statistical Informational Systems (SPSS) in particular the other one is for Marketing Planning project which is on the topic of Marketing Plan about the Selling of a Marketing TextBook. First I should mention yesterday I prayed to the Lord to help to a friend of mine which desperately needed money to bless him with money and Hooray the Lord was fast. Today a guys who promised from an AutoWashing company called him and gave him the job on and he is now on a trial period. Praise the Lord and His Mighty Deeds! 🙂 Also now in the evening an Evolink techsupport called me to halt pozvanete’s server, because he had to mount the one 4 GB bank to the server. All went fine 🙂 I should also note that God is giving me his abundant grace eventhough I don’t deserve it.END—–