Results 1 to 4 of 4

Thread: SQLite beginner question...

  1. #1
    Join Date
    Aug 2009
    Posts
    4
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default SQLite beginner question...

    This is a basic SQLite question...so basic I am afraid no one has asked this stupid of a question...

    So in the sample code for 'Music Archive' under the SQL section there is a database.h file that has this code snippet:
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName(":memory:");

    I get that the database will be in memory and is just virtual. But what if I make a slight change:
    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName("test.db");

    From the documentation it says it will try to open test.db, and if it doesn't exist it will create it, which makes sense. But where is it created. If I run the program and leave the program running I would expect to be able to find the test.db file....but it isn't there. I am building it on a Mac at the moment. I glanced through the code to see if I could see it was opening the DB file and then closing or deleting it, therefor I wasn't able to see it. But I didn't see anything.

    What I want to do is open an XML file read it in and insert the contents of the XML file into a DB file. But I need to create a physical SQLite file. I was just looking at the sample code and everything is using :memory:. Any insight would be appreciated.

    The Mac

  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: SQLite beginner question...

    The database is normally created under QCoreApplication::applicationDirPath(). See there.

  3. The following user says thank you to Lykurg for this useful post:

    theMac (1st September 2009)

  4. #3
    Join Date
    Aug 2009
    Posts
    4
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: SQLite beginner question...

    Thanks, I appreciate the response. That was what I needed to know. This was my first time doing development on a Mac. After you response I dropped down to the command line and ran a find command and it matched the variable you mention in your thread. Thanks again.

  5. #4
    Join Date
    Aug 2009
    Posts
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: SQLite beginner question...

    I have UIC files...How can i get them in .h and .cpp files?

Similar Threads

  1. How to Run Sqlite in Windows Mobile
    By Comptrol in forum Qt Programming
    Replies: 0
    Last Post: 26th June 2009, 12:19
  2. sqlite version in Qt
    By janus in forum Newbie
    Replies: 4
    Last Post: 5th February 2009, 14:18
  3. question about sqlite ( qt 4 )
    By msmihai in forum Qt Programming
    Replies: 2
    Last Post: 19th December 2008, 08:35
  4. SQLite - check if any records are returned
    By amicitas in forum Newbie
    Replies: 1
    Last Post: 28th September 2008, 10:28
  5. Beginner C++ question
    By masoroso in forum General Programming
    Replies: 2
    Last Post: 19th April 2006, 14:15

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.