Results 1 to 3 of 3

Thread: Problem replicating a MySQL on SQLite

  1. #1
    Join Date
    Dec 2010
    Posts
    18
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Problem replicating a MySQL on SQLite

    Hi, I'm replicating a remote MySQL database onto a local SQLite database with QT4, SELECTing the remote data and INSERTing it into the local database.

    On Windows it worked flawlessly, but on Linux I'm facing encoding problems, with stuff like Euro symbols (€) or Spanish accents (áéÃ*óú). The original MySQL database has the schema set to UTF8:

    Qt Code:
    1. CREATE SCHEMA IF NOT EXISTS `4access` DEFAULT CHARACTER SET UTF8
    To copy to clipboard, switch view to plain text mode 

    Accessing directly using the mysql client, everything is fine:

    Qt Code:
    1. mysql> select * from currency;
    2. +-------+---------+---------+-----------+---------+---------------------+
    3. | cu_id | cu_name | cu_code | cu_symbol | cu_rate | version |
    4. +-------+---------+---------+-----------+---------+---------------------+
    5. | 1 | Euro | EU | € | 1 | 2010-12-15 20:28:04 |
    6. | 2 | Dollar | US | $ | 1.5 | 2010-12-15 20:28:04 |
    7. | 3 | Pound | UK | £ | 0.8 | 2010-12-15 20:28:04 |
    8. +-------+---------+---------+-----------+---------+---------------------+
    To copy to clipboard, switch view to plain text mode 

    But after replicating the database with my application, I open the sqlite databse and some characters are screwed:

    Qt Code:
    1. sqlite> select * from currency;
    2. 1|Euro|EU|€|1.0|2010-12-15T20:28:04
    3. 2|Dollar|US|$|1.5|2010-12-15T20:28:04
    4. 3|Pound|UK|£|0.8|2010-12-15T20:28:04
    To copy to clipboard, switch view to plain text mode 

    Does anyone know where the problem can be?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Problem replicating a MySQL on SQLite

    You don't tell us exactly how you do the transfer. It seems likely that the character set on your connection (different from the database char set) to the Mysql database is Latin-1 rather than UTF-8. From the mysql man page:
    · --default-character-set=charset_name

    Use charset_name as the default character set for the client and
    connection.

    A common issue that can occur when the operating system uses utf8
    or another multi-byte character set is that output from the mysql
    client is formatted incorrectly, due to the fact that the MySQL
    client uses the latin1 character set by default. You can usually
    fix such issues by using this option to force the client to use the
    system character set instead.

    See Section 9.5, “Character Set Configuration”, for more
    information.

  3. #3
    Join Date
    Dec 2010
    Posts
    18
    Thanks
    4
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: Problem replicating a MySQL on SQLite

    Sorry, didn't see your reply. I fixed the problem issuing a SET NAMES UTF8 right after I open my MySQL connection

Similar Threads

  1. Qt-Sqlite problem
    By emresahin in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 25th June 2010, 06:44
  2. Plugin SQLite/Mysql non trouvés
    By keo in forum Installation and Deployment
    Replies: 0
    Last Post: 10th September 2009, 08:47
  3. Replies: 1
    Last Post: 16th July 2009, 02:25
  4. SQLite Problem
    By natbobc in forum Qt Programming
    Replies: 5
    Last Post: 8th November 2007, 15:31
  5. Problem with SqLite and Qt
    By ad5xj in forum Newbie
    Replies: 26
    Last Post: 5th June 2007, 01:53

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.