Results 1 to 5 of 5

Thread: Accessing SQLite3 db files from different locations

  1. #1
    Join Date
    Apr 2010
    Posts
    77
    Thanks
    10
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Accessing SQLite3 db files from different locations

    Probably a very silly question but...
    I'm on a Leopard OS X Mac.

    When I type "sqlite3 test1.db" at the command line it creates test.db in my home directory.
    When I open db "test2.db" from within a QT application, it creates test.db in the application build folder.

    How do I access test2.db from the command line?
    How do I open test1.db from within my QT application?

    Cheers
    Jeff

  2. #2
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: Accessing SQLite3 db files from different locations

    Yep, this is a stupid question..... Naaaaa.... There is no such thing as a stupid question.

    You can always give a full path, e.g. sqlite3 /home/foo/bar/.config/mysqlite.db
    Works on command line as much as parameter to use from within Qt.

  3. #3
    Join Date
    Apr 2010
    Posts
    77
    Thanks
    10
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Accessing SQLite3 db files from different locations

    I got it working from within QT by using

    Qt Code:
    1. QString aDBFilePath = QDir::homePath() + "/test.db";
    To copy to clipboard, switch view to plain text mode 

    But still couldn't get it working from the terminal/console.
    It just doesn't create a database.

  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: Accessing SQLite3 db files from different locations

    have you the permissions for creating a file at that position?

  5. #5
    Join Date
    Apr 2010
    Posts
    77
    Thanks
    10
    Thanked 7 Times in 6 Posts
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Accessing SQLite3 db files from different locations

    I've sorted it out.
    Using:

    ./aDirectory/test.db

    worked fine.
    What was getting me is that the database wasn't showing up until I created a table in it.

    Thanks
    Jeff

Similar Threads

  1. find bin, lib and include locations
    By Adrian Sevcenco in forum Installation and Deployment
    Replies: 4
    Last Post: 18th October 2009, 13:39
  2. Replies: 12
    Last Post: 17th June 2009, 05:34
  3. SQLite3 and Qt
    By k12yp70n in forum Newbie
    Replies: 3
    Last Post: 18th March 2009, 15:18
  4. QDockWidget locations
    By elcuco in forum Qt Programming
    Replies: 7
    Last Post: 30th January 2008, 21:00
  5. Replies: 5
    Last Post: 18th April 2007, 20:02

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.