import data - how to change code page on the fly

This is a discussion on import data - how to change code page on the fly within the MySQL Database forums, part of the Database Forums category; hello, my database has table in latin2. Flat file with data which I would like to import to db is ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-15-2007
aaooo54
 
Posts: n/a
Default import data - how to change code page on the fly

hello,
my database has table in latin2. Flat file with data which I would like to
import to db is coded in cp1250 charset.
As far as I know there is no way to import data to db and auto-magic change
code page of data on the fly. Am I correct?:)

And main question I kindly ask you: why following set of queries give me
wrong results:
SET NAMES binary; --I supposed that means "dont interpret future data"
LOAD DATA infile (...cut....) -- loading data...
SET NAMES cp1250; --ok, let talk with me in cp1250 code page
select * from t; --no way! db returns data as latin2 according to table
charset

why "SET NAMES cp1250" is ignored?

regards,
Robert




Reply With Quote
  #2 (permalink)  
Old 11-16-2007
lark
 
Posts: n/a
Default Re: import data - how to change code page on the fly

== Quote from aaooo54 (roobik@poczta.onet.pl)'s article
> hello,
> my database has table in latin2. Flat file with data which I would like to
> import to db is coded in cp1250 charset.
> As far as I know there is no way to import data to db and auto-magic change
> code page of data on the fly. Am I correct?:)
> And main question I kindly ask you: why following set of queries give me
> wrong results:
> SET NAMES binary; --I supposed that means "dont interpret future data"
> LOAD DATA infile (...cut....) -- loading data...
> SET NAMES cp1250; --ok, let talk with me in cp1250 code page
> select * from t; --no way! db returns data as latin2 according to table
> charset
> why "SET NAMES cp1250" is ignored?
> regards,
> Robert



it is possible that the column definitions have latin2 encoding. if this is the case it wouldn't matter what
language you set yourself up in the command line, the table attributes won't understand it. post a
description of the table and a sample of your data infile if you can.
--
POST BY: lark with PHP News Reader ;o)
Reply With Quote
  #3 (permalink)  
Old 11-16-2007
aaooo54
 
Posts: n/a
Default Re: import data - how to change code page on the fly

> it is possible that the column definitions have latin2 encoding.
ok, i have checked with table definied as CHARSET=cp1250

import script is as follow:
SET NAMES cp1250;
SET CHARACTER SET cp1250;
LOAD DATA ...

flat file is saved as cp1250 for sure.

Error occured when script tried insert first column with character specified
to cp1250 code page and innconsistent with code page of database (latin2)
Ridiculous mysql message is "Data truncation: Data too long for column"

At the moment my workaround is to change code page of flat file before I
import them to the db but I believe that solution exists in mysql;)

regards,
R.



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 06:07 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0