Results 1 to 5 of 5

Thread: Using SQLite database on Symbian

  1. #1
    Join Date
    Mar 2009
    Posts
    98
    Thanks
    3
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Using SQLite database on Symbian

    Hi, I've got some strange problems using a sqlite dabatase on my nokia N78.

    I add my sqlite db on my .pro file in this way:
    Qt Code:
    1. # Add files and directories to ship with the application
    2. # by adapting the examples below.
    3. # file1.source = myfile
    4. # dir1.source = mydir
    5. file.source = sms.sqlite
    6. file.path = C:/workspace/SMSArchive
    7. DEPLOYMENTFOLDERS += file
    8.  
    9. symbian:TARGET.UID3 = 0xE37DE095
    10.  
    11. # Allow network access on Symbian
    12. #symbian:TARGET.CAPABILITY += NetworkServices
    13.  
    14. # If your application uses the Qt Mobility libraries, uncomment
    15. # the following lines and add the respective components to the
    16. # MOBILITY variable.
    17. # CONFIG += mobility
    18. # MOBILITY +=
    19.  
    20. QT += sql
    21.  
    22. #SOURCES, HEADERS are OK!
    23.  
    24. # Please do not modify the following two lines. Required for deployment.
    25. include(deployment.pri)
    26. qtcAddDeployment()
    To copy to clipboard, switch view to plain text mode 

    Then if I try to install my program on the phone memory I can query my data correctly, but if I install it on the external memory card it doesn't work!

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Using SQLite database on Symbian

    would be nice to see what deployment.pri looks like and how you are calling your database. On Symbian it could be important to use QDir::toNativeSeparators() before setting the database.

  3. #3
    Join Date
    Mar 2009
    Posts
    98
    Thanks
    3
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using SQLite database on Symbian

    The deplyment.pri is that QtCreator provides me.

    Qt Code:
    1. # checksum 0xfb0c version 0x30001
    2. # This file was generated by an application wizard of Qt Creator.
    3. # The code below handles deployment to Symbian and Maemo, aswell as copying
    4. # of the application data to shadow build directories on desktop.
    5. # It is recommended not to modify this file, since newer versions of Qt Creator
    6. # may offer an updated version of it.
    7.  
    8. defineTest(qtcAddDeployment) {
    9. for(deploymentfolder, DEPLOYMENTFOLDERS) {
    10. item = item$${deploymentfolder}
    11. itemsources = $${item}.sources
    12. $$itemsources = $$eval($${deploymentfolder}.source)
    13. itempath = $${item}.path
    14. $$itempath= $$eval($${deploymentfolder}.target)
    15. export($$itemsources)
    16. export($$itempath)
    17. DEPLOYMENT += $$item
    18. }
    19.  
    20. MAINPROFILEPWD = $$PWD
    21.  
    22. symbian {
    23. isEmpty(ICON):exists($${TARGET}.svg):ICON = $${TARGET}.svg
    24. isEmpty(TARGET.EPOCHEAPSIZE):TARGET.EPOCHEAPSIZE = 0x20000 0x2000000
    25. } else:win32 {
    26. copyCommand =
    27. for(deploymentfolder, DEPLOYMENTFOLDERS) {
    28. source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
    29. source = $$replace(source, /, \\)
    30. sourcePathSegments = $$split(source, \\)
    31. target = $$OUT_PWD/$$eval($${deploymentfolder}.target)/$$last(sourcePathSegments)
    32. target = $$replace(target, /, \\)
    33. !isEqual(source,$$target) {
    34. !isEmpty(copyCommand):copyCommand += &&
    35. copyCommand += $(COPY_DIR) \"$$source\" \"$$target\"
    36. }
    37. }
    38. !isEmpty(copyCommand) {
    39. copyCommand = @echo Copying application data... && $$copyCommand
    40. copydeploymentfolders.commands = $$copyCommand
    41. first.depends = $(first) copydeploymentfolders
    42. export(first.depends)
    43. export(copydeploymentfolders.commands)
    44. QMAKE_EXTRA_TARGETS += first copydeploymentfolders
    45. }
    46. } else:unix {
    47. maemo5 {
    48. installPrefix = /opt/usr
    49. desktopfile.path = /usr/share/applications/hildon
    50. } else {
    51. installPrefix = /usr/local
    52. desktopfile.path = /usr/share/applications
    53. copyCommand =
    54. for(deploymentfolder, DEPLOYMENTFOLDERS) {
    55. source = $$MAINPROFILEPWD/$$eval($${deploymentfolder}.source)
    56. source = $$replace(source, \\, /)
    57. macx {
    58. target = $$OUT_PWD/$${TARGET}.app/Contents/Resources/$$eval($${deploymentfolder}.target)
    59. } else {
    60. target = $$OUT_PWD/$$eval($${deploymentfolder}.target)
    61. }
    62. target = $$replace(target, \\, /)
    63. sourcePathSegments = $$split(source, /)
    64. targetFullPath = $$target/$$last(sourcePathSegments)
    65. !isEqual(source,$$targetFullPath) {
    66. !isEmpty(copyCommand):copyCommand += &&
    67. copyCommand += $(MKDIR) \"$$target\"
    68. copyCommand += && $(COPY_DIR) \"$$source\" \"$$target\"
    69. }
    70. }
    71. !isEmpty(copyCommand) {
    72. copyCommand = @echo Copying application data... && $$copyCommand
    73. copydeploymentfolders.commands = $$copyCommand
    74. first.depends = $(first) copydeploymentfolders
    75. export(first.depends)
    76. export(copydeploymentfolders.commands)
    77. QMAKE_EXTRA_TARGETS += first copydeploymentfolders
    78. }
    79. }
    80. for(deploymentfolder, DEPLOYMENTFOLDERS) {
    81. item = item$${deploymentfolder}
    82. itemfiles = $${item}.files
    83. $$itemfiles = $$eval($${deploymentfolder}.source)
    84. itempath = $${item}.path
    85. $$itempath = $${installPrefix}/share/$${TARGET}/$$eval($${deploymentfolder}.target)
    86. export($$itemfiles)
    87. export($$itempath)
    88. INSTALLS += $$item
    89. }
    90. icon.files = $${TARGET}.png
    91. icon.path = /usr/share/icons/hicolor/64x64/apps
    92. desktopfile.files = $${TARGET}.desktop
    93. target.path = $${installPrefix}/bin
    94. export(icon.files)
    95. export(icon.path)
    96. export(desktopfile.files)
    97. export(desktopfile.path)
    98. export(target.path)
    99. INSTALLS += desktopfile icon target
    100. }
    101.  
    102. export (ICON)
    103. export (INSTALLS)
    104. export (DEPLOYMENT)
    105. export (TARGET.EPOCHEAPSIZE)
    106. export (TARGET.CAPABILITY)
    107. export (LIBS)
    108. export (QMAKE_EXTRA_TARGETS)
    109. }
    To copy to clipboard, switch view to plain text mode 

    And the piece of code where I open the database.
    Qt Code:
    1. QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE", "sms");
    2. db.setDatabaseName("sms.sqlite");
    3. if (!db.open()) {
    4. QMessageBox::critical(0,
    5. QObject::tr("Opening database"),
    6. QObject::tr("Failled to open the database"));
    7. return -1;
    8. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Using SQLite database on Symbian

    Quote Originally Posted by PaceyIV View Post
    The deplyment.pri is that QtCreator provides me.
    Ha, that must be new... I wasn't aware of that...

    Anyway, seem highly to be some path issues. So for debug see what's the value of QDir::currentPath() when you call setDatabaseName. Is it pointing to the right directory and where did the sis file install the database at the external memory card?

  5. #5
    Join Date
    Mar 2009
    Posts
    98
    Thanks
    3
    Thanked 9 Times in 9 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Using SQLite database on Symbian

    When I install on phone memory QDir::currentPath() is "C:/Private/e37de095". I can't access to this path to check what contain.
    When I install on memory card, the path is "E:/Private/e37de095". In this directory I can see my "sms.sqlite" and nothing else.
    If I try to open my db in this way, I get the error: unable to open database file Error opening database. But dbPath is right! QFile doesn't say me that the file doesn't exist!

    Qt Code:
    1. QString dbPath = QDir::currentPath();
    2. dbPath += QDir::separator();
    3. dbPath += DB_FILENAME;
    4. dbPath = QDir::cleanPath(dbPath);
    5.  
    6. qDebug() << QDir::currentPath();
    7. qDebug() << dbPath;
    8.  
    9. if (!QFile::exists(dbPath)) {
    10. qDebug() << "db not found!";
    11. return -1;
    12. }
    13.  
    14. QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    15. db.setDatabaseName(dbPath);
    To copy to clipboard, switch view to plain text mode 
    Last edited by PaceyIV; 11th May 2011 at 23:06.

Similar Threads

  1. Sqlite Database
    By sabbu in forum Qt Programming
    Replies: 5
    Last Post: 16th May 2011, 13:07
  2. connection to sqlite database using qt4
    By elimelick in forum Newbie
    Replies: 0
    Last Post: 25th July 2010, 14:53
  3. How to insert row to SQLite database?
    By MIH1406 in forum Qt Programming
    Replies: 6
    Last Post: 29th May 2010, 12:22
  4. SQLITE ATTACH database
    By drescherjm in forum Qt Programming
    Replies: 8
    Last Post: 9th December 2009, 07:25
  5. SQLITE database problems
    By phoenix in forum Newbie
    Replies: 3
    Last Post: 30th April 2007, 21:38

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.