Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Apr 2012
    Posts
    104
    Thanks
    27
    Thanked 2 Times in 2 Posts

    Exclamation Converting SQL to XML?

    I have a SQL file whose data i need to use, but i dont know how to even open it, how can i convert it to XML file so i can use all data by Javascript?
    Everything is simpler with jQuery!

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,246
    Thanks
    12
    Thanked 340 Times in 336 Posts
    Quote Originally Posted by Peeyush View Post
    I have a SQL file whose data i need to use, but i dont know how to even open it,
    with a simple text editor.

    you don’t need to convert it to XML either as JS is able to read a text file as string.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #3
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,459
    Thanks
    1
    Thanked 23 Times in 21 Posts
    Uh, I don't mean to rain on the parade, but I think we need a little more info.

    Are you talking about a SQL query statement file of the form
    Code:
    INSERT foo INTO bar ...
    Or are you talking the actual database, which may have the data encoded in binary?

    Also, may I ask what kind of database it is? MySQL? SQLite?
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #4
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    If your SQL file can be imported into MySQL then I would suggest using phpMyAdmin to import the file into a MySQL database. Then export it using phpMyAdmin which will allow you to create a JSON based file. Or if you will be using this with a PHP based site then you can also export it into a file containing PHP data structures. Lots of options on format with phpMyAdmin.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #5
    Regular Coder
    Join Date
    Apr 2012
    Posts
    104
    Thanks
    27
    Thanked 2 Times in 2 Posts
    hi guys. Thankr for all replies. Its a file with .sql extention, and most probably contains only data. Can it be 100 per cent converted to json based file or will some bits remain as it is?
    Everything is simpler with jQuery!

  • #6
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Quote Originally Posted by Peeyush View Post
    hi guys. Thankr for all replies. Its a file with .sql extention, and most probably contains only data. Can it be 100 per cent converted to json based file or will some bits remain as it is?
    Couldn't say. Have never exported it in that format before. It's just one of the many export formats phpMyAdmin supports.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #7
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,246
    Thanks
    12
    Thanked 340 Times in 336 Posts
    .sql files are often just dumps of the database. so there is also the information about how to create the table (and such).
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • Users who have thanked Dormilich for this post:

    Peeyush (05-25-2012)

  • #8
    Regular Coder
    Join Date
    Apr 2012
    Posts
    104
    Thanks
    27
    Thanked 2 Times in 2 Posts
    yeah, when i try to import it, it stops and spots an error which says that some table is missing, but i know that SQL file cant be wrong, hundreds of people use the same, difference is, they use php mysql combination, while i want to use javascript/jason or xml
    Everything is simpler with jQuery!

  • #9
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,246
    Thanks
    12
    Thanked 340 Times in 336 Posts
    Quote Originally Posted by Peeyush View Post
    yeah, when i try to import it, it stops and spots an error which says that some table is missing
    that’s an error on SQL level. no matter which way of importing you use, unless you fix that particular problem, neither will work.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #10
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Quote Originally Posted by Peeyush View Post
    yeah, when i try to import it, it stops and spots an error which says that some table is missing, but i know that SQL file cant be wrong, hundreds of people use the same, difference is, they use php mysql combination, while i want to use javascript/jason or xml
    Probably means it was exported with data only and not structure. You would need the structure of the database to import it into a new database.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •