Sqlite3 implementation of Chinese path SQL file import alternative solution

Source: Internet
Author: User
Tags sqlite

1. The requirement program to achieve the product offline data download, it uses the Java side directly splicing SQL files, the client download SQL files, merged into the local database. Performance also line LAN more than 10 seconds more than 7 trillion, but there is a sqlite or SQL file saved in the Chinese path can not be merged with the problem 2. The main reason is that when SQLite opens the database with UTF8 open, QT generally uses Unicode encoding. There are many methods on the Internet, here we adopt another method to solve the problem of avoiding Chinese path by relative path 3. Code Snippet 1. Create a database
    "/db");    dir("");    dir.mkpath(strdbpath);    "/mysqlite.db";    QSqlDatabase dbset = QSqlDatabase::addDatabase("QSQLITE""file");    dbset.setDatabaseName(strdbpath);    if (!dbset.open()) {        LOG_ALL_ERROR(QStringLiteral("failed open mysqlite.db"));        return bret;    }
2. Merging SQL files to the local database
std::string strstdcmd("sqlite3.exe ./db/mysqlite.db \".read ./db/mysqlite.sql\"");    process;    process.start(strstdcmd.c_str());    process.waitForFinished();    String"/db/mysqlite.sql");    QFile::remove(strsqlpath);
3. Download the SQL file section slightly with Libcurl it is easy and quick to download the file 4. Note 1. Code in Win7+vs2010+qt5.40+libcurl 7.36.0 compiled by 2. Compile or direct download Sqlite3.exe in the generated directory and the source directory is stored in a copy of 3. Common sense Currentpath at compile time refers to the source directory, directly run EXE refers to the directory of EXE

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Sqlite3 implementation of Chinese path SQL file import alternative solution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.