Results 1 to 3 of 3

Thread: Executing SQL scripts from a file

  1. #1
    Join Date
    Jun 2007
    Posts
    24
    Thanks
    11
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question Executing SQL scripts from a file

    Qt version: 4.3.0
    DB: SqLite
    When the application starts, I like to create databases/tables and populate tables with some data. These statements can conveniently be put in a script file. What is the recommended way of doing this in Qt?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Executing SQL scripts from a file

    Read a statement into QString, pass it into QSqlQuery and execute it. Read another statement, etc.

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

    Default Re: Executing SQL scripts from a file

    Quote Originally Posted by William Wilson View Post
    Qt version: 4.3.0
    DB: SqLite
    When the application starts, I like to create databases/tables and populate tables with some data. These statements can conveniently be put in a script file. What is the recommended way of doing this in Qt?
    I cannot show you the recommended way, but I do it this way:
    http://comicmaster.svn.sourceforge.n...10&view=markup

    See methods 'createDatabase' and 'createTables'.

    This is the data file I use to create my database:

    http://comicmaster.svn.sourceforge.n...ql?view=markup

  4. The following 2 users say thank you to Kumosan for this useful post:

    ChrisW67 (8th July 2009), William Wilson (7th September 2007)

Similar Threads

  1. qt-3.3.8 fail in scratchbox
    By nass in forum Installation and Deployment
    Replies: 0
    Last Post: 25th May 2007, 16:21
  2. Can I use the Sql Module without chanage .pro file?
    By fengtian.we in forum Qt Programming
    Replies: 9
    Last Post: 21st May 2007, 11:59

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.