×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    26

    SQlite and Qt on Symbian

    Hi
    I am building some app which uses sqlite database. When I create database, put it in my project folder, put DEPLOYMENT in .pro file (and write function for open database, of course) and build app for mobile phone - installer copies my database file on !:/data/app_name, but app won't connect to database...

    when I create database in memory of phone, I can normally run sql queries, but, when I close app - all changes are gone...

    Does anyone have idea how to connect to database file?

    here are some code snippets:
    Code:
    from my_app.pro
    QT += sql gui core
    
    data.sources = dat/*.dat
    data.path = !:/Data/my_app/
    DEPLOYMENT =  data
    Code:
    from my_app.cpp
    
    bool MainWindow::openDB()
    {
        //find sqslite driver
        db = QSqlDatabase::addDatabase("QSQLITE");
        db.setDatabaseName(QDir::rootPath() + "/my_app/data.dat");
        if (!db.open()){
            QMessageBox::critical(0, QString::fromUtf8("error!"), QString::fromUtf8("error"));
            return false;
        }else{
            QMessageBox::information(0, "Q'apla!", QString::fromUtf8("sucess"));
    
        return true;}
    }
    error strings are just for debugging, final application will have "normal" strings

    I call openDB() in main function, just before app.exec()

  2. #2
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: SQlite and Qt on Symbian

    SQLite requires that the path be in "native' form. Use QDir::toNativeSeparators to transform the path into one that SQLite likes.

    Or, if you have no need to expose the DB externally, simply place it in the application private directory and specify no directory path at all.

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    26

    Re: SQlite and Qt on Symbian

    actually, I dont need to expose database externally, but I didn't know how to deploy it to app private directory.
    I assume, if I put database in app private directory, I'd need just write filename (it can basically be without extension)...

    What should I write in data.path (in project file), to put database in private dir?

  4. #4
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: SQlite and Qt on Symbian

    data.path = .

  5. #5
    Registered User
    Join Date
    Jan 2009
    Posts
    26

    Re: SQlite and Qt on Symbian

    thank you!

Similar Threads

  1. Add existing Sqlite database to Qt project
    By santijdelatorre in forum Qt
    Replies: 31
    Last Post: 2011-05-15, 01:20
  2. DQuest - ORM framework for Qt/Sqlite
    By benlaud in forum [Archived] Qt SDKs and Tools
    Replies: 0
    Last Post: 2010-10-05, 05:13
  3. Replies: 2
    Last Post: 2010-06-02, 23:10

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×