Results 1 to 12 of 12

Thread: export SQL query to XML

  1. #1
    Join Date
    Oct 2011
    Location
    Toronto Canada
    Posts
    97
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default export SQL query to XML

    How would I be able to take a SQL Statement and convert the results to XML

    i have a PHP script that does it now and i call the php script from my application but i would much rather the application do that for me instead of an outside php script

    any insight would be greatly appreciated

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

    Default Re: export SQL query to XML

    What's the problem exactly? Seems like an easy task.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Oct 2011
    Location
    Toronto Canada
    Posts
    97
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: export SQL query to XML

    it seems as if i would query the data then write that to an xml

    how would i go about doing so
    Last edited by prophet0; 2nd February 2012 at 15:31.

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

    Default Re: export SQL query to XML

    Ok, but which part of the task you are having problems with? Did you look at available classes? Which seemed like ones that might suit the task? Did you do any research about the subject or do you just expect someone to give you a ready solution so that you don't have to bother?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Oct 2011
    Location
    Toronto Canada
    Posts
    97
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: export SQL query to XML

    i dont expect anyone to write anything i wont learn that way

    i have been researching but cant get a grasp on what would i use as my container like would i use a sqlquerymodel to hold my data and then write the model to xml using dom or stream

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

    Default Re: export SQL query to XML

    It seems you are on the right track. What's the problem then?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Oct 2011
    Location
    Toronto Canada
    Posts
    97
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: export SQL query to XML

    well writing the document if i have a query like

    Qt Code:
    1. SELECT *
    2. FROM advertisementstrings
    3. WHERE advertisementstrings.LanguageID = '1'
    To copy to clipboard, switch view to plain text mode 

    and i would like to have

    <root>
    <myinfo>
    </myinfo>
    </root>

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

    Default Re: export SQL query to XML

    I still fail to see the problem You have QSqlQuery or QSqlQueryModel to execute the query and QDomDocument or QXmlStreamWriter to write the data to xml (my personal choice would be to go for QSqlQuery and QXmlStreamWriter in this case but that's mostly a matter of taste unless your query is going to return thousands of rows). For such an easy document you can even write to the file directly instead of using any xml tools, there is not much processing here.

    If you ask a specific question then I will do my best to give you a specific answer but so far I haven't seen any questions here (not even a single question mark in your posts).
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Oct 2011
    Location
    Toronto Canada
    Posts
    97
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: export SQL query to XML

    sorry i will explain

    i have a device (linux) that will connect to MYSQL Database to gather information but sometimes it will not have internet connection to get data from webserver this is why im trying to get sql data then write to xml on local hdd and read from there when no internet connection is available


    im sorry to confuse and not explain im new to qt

    if there is an easier way to do this please let me know but as far as i can see xml would be good to store on local hdd for access

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

    Default Re: export SQL query to XML

    XML is ok. You could also use an SQLite database. There is an additional benefit in this case that it's not that trivial to modify the contents of such file if you care about integrity of the data.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    Oct 2011
    Location
    Toronto Canada
    Posts
    97
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: export SQL query to XML

    SQL error sorry!! ignore this post
    Last edited by prophet0; 14th February 2012 at 20:32.

  12. #12
    Join Date
    Oct 2011
    Location
    Toronto Canada
    Posts
    97
    Thanks
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: export SQL query to XML

    Ok so i have done what you have suggested (Fairly easy) so i get why i was confused

    Thanks wysota

Similar Threads

  1. Cryptography and export
    By DanH in forum Qt Programming
    Replies: 0
    Last Post: 13th April 2011, 15:42
  2. Export StandardItemModel to XML
    By homerun4711 in forum Newbie
    Replies: 2
    Last Post: 23rd December 2010, 08:10
  3. how to export dll with gui?
    By cutie.monkey in forum Qt Programming
    Replies: 5
    Last Post: 14th November 2009, 02:19
  4. Export SVG: Qwt Bug?
    By giusepped in forum Qwt
    Replies: 4
    Last Post: 19th December 2008, 10:50
  5. DLL export problem
    By hrcariaga in forum Qt Programming
    Replies: 5
    Last Post: 12th February 2008, 06:26

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
  •  
Qt is a trademark of The Qt Company.