-
we are working in codeblocks.we have created a console input output application.we have connected mysql as the database.now we want that whatever we query the result of the query should be stored in a text file.please guide.0
-
Administrator • May 30, 2013
I'll assume you're on Windows operating system and console is your DOS prompt. In this situation, you will have to use the redirect operator.bnswe are working in codeblocks.we have created a console input output application.we have connected mysql as the database.now we want that whatever we query the result of the query should be stored in a text file.please guide.
Let's say you want to capture the output of a 'DIR' command to a text file, you will have to issue the following command -
C:\>DIR >log.txt
This will store the output of DIR command to log.txt. However, if you execute the above command multiple times, the command will delete the previous contents. If you want to 'log' all the outputs one after the other, you will have to use the >> operator.
C:\>DIR >>log.txt
Now this will keep on adding the output of DIR command to log.txt one after the other in the form of a log file.
I'm not sure if the following would work, but you may try giving it a try -
C:\> CONSOLE >>log.txt
This should log everything on the console to a text file.
Someone more familiar with DOS can help. Let us know if that helps.Are you sure? This action cannot be undone. -
Member • May 30, 2013
where do we have to run this command?in codeblocks this command generated lot of errorsAre you sure? This action cannot be undone. -
Administrator • May 30, 2013
You run these commands in your DOS console. I'm not sure what you're trying to do. You will have to explain your problem a bit in more detail so that there's no room for assumption.bnswhere do we have to run this command?in codeblocks this command generated lot of errors
We can't know which console you're referring to, which operating system you are using and what kind of errors you are getting.Are you sure? This action cannot be undone. -
Member • May 31, 2013
we are using windows os and console is the screen where we get output after running any standard c++ program using codeblocks.
now we have connected mysql to codeblocks and succesfully running the queries to get the result on console.what we want is to save the displayed result of queries in a text file just like we do in file handling.Are you sure? This action cannot be undone. -
Member • May 31, 2013
#-Link-Snipped-# I guess u are talking about mysql console, 👀, if thats the case, u can simple use the select statement with into outfile option to get it to write to the text file.
For example your query is:
select * from testTable;
to write result in file, u will have to write as :
select * into outfile 'output.txt' from testTable;
It should solve your problem👍😀Are you sure? This action cannot be undone. -
Member • May 31, 2013
I think you want it to be done automatically, so add a statement in your program
cmd.setCommandText(_TSA("the query given by rahul69"));
cmd.Execute();
NOTE: this is using SQLAPI.hAre you sure? This action cannot be undone. -
Member • Jun 5, 2013
thanks for the help. can u tell us how to convert mysql database into .xml file?Are you sure? This action cannot be undone. -
Member • Jun 6, 2013
database into xml?? can you be a li'l clear?bnsthanks for the help. can u tell us how to convert mysql database into .xml file?Are you sure? This action cannot be undone. -
Member • Jun 6, 2013
sir,we want our relational database table which is in mysql to be converted into xml file.Vishal0203database into xml?? can you be a li'l clear?Are you sure? This action cannot be undone. -
Member • Jun 7, 2013
i don't know the exact way but, I can tell you a technique which you may find helpful.bnssir,we want our relational database table which is in mysql to be converted into xml file.
If you store your table in a .doc or .docx file, just go to the file location, right click, change the file extension from .doc or . docx to .rar
When you are done, open the .rar file with Winrar or some other supporting software
you'll have a number of .xml files inside the .rar file, which stores all the formatting of table and the contents.. (extension can be changed through program too)
I'm not sure whether this will be helpful or not, still give a try!Are you sure? This action cannot be undone.