Thanks, your suggestion worked perfect!

:)

On Wed, Nov 24, 2010 at 10:40 AM, Pierpaolo Bernardi <olopie...@gmail.com>wrote:

> On Wed, Nov 24, 2010 at 15:55, Kevin Turner <kevin.j.tur...@gmail.com>
> wrote:
> > I'm trying to attach one database to another but they have different
> > encoding schemas. One is UTF-16le and the other is UTF-8. I get this
> error
> > message when I try to attach:
> >
> > Error: attached databases must use the same text encoding as main
> database
> >
> > According to the sqlite FAQ, once an encoding has been set for a
> database,
> > it cannot be changed. Fair enough. But is it possible to *recreate* an
> > existing database and set the encoding type before the create table
> > statements are run?
> >
> > I tried doing this to the table that uses UTF-16le:
> >
> >  BEGIN TRANSACTION;
> >  CREATE TEMPORARY TABLE tmp(...);
> >  INSERT INTO tmp(...) SELECT ... FROM questions;
> >  DROP TABLE mytable;
> >  PRAGMA encoding = "UTF-8";
> >  CREATE TABLE mytable(...);
> >  INSERT INTO mytable(...) SELECT ... FROM tmp;
> >  COMMIT;
> >
> > But it didn't work, the newly rebuilt database was still UTF-16le. Any
> > suggestions on this? I'm a sqlite n00b and not a database specialist, so
> > verbosity in your responses would be much appreciated. ;)
>
> probably not the best solution, but the following should work:
>
> - sqlite3 your-utf16-db .dump > qqq
> - edit qqq appropriately, with a text editor
> - sqlite3 -init qqq the-converted-db-name
>
> P.
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to