View Full Version : Can I use SQL to save a column of data to a text file?
Mr Paul Jones
May 14th, 2007, 10:50 PM
Basically I don't want my msSQL database accessed directly through a website, mainly because I don't want it working any harder than it should be.
I want to show specific statistics on my website that will be pulled from the database say once per day and saved to a text file that will be CALLed by the website.
I was thinking I have two options, create an SQL script or create an application to do it. SQL seems the most appropriate way.
What I ask is, is this possible? And can someone point me in the right direction?
Thanks :P
BetaWar
May 14th, 2007, 11:55 PM
Well, in theory it is possible, I am not sure why you would want to do it, but it is possible.
You will need to use your database anyway to make sure that the information has already been pulled for each day.
Basically you will need to create a table that has the date and when the information has been pulled. Then you have it set so that it checks if the database has been queried already tht day, if so it does nothing, otherwise it will need to pull out the information and save it the the correct file.
The reason I think you shouldn't worry about this is that it will have to access the database anyways to tell if the information has been accessed or not. It is far easier to just pull the information each time, as you will need to do the same thing anyways; just from a file instead.
I am not sure you know this, but MySQL uses the same bandwidth that the rest of your pages uses so you aren't really saving any work in this process.
Again, if you are set on doing it this way, you will still need to use a database.
puppy
May 15th, 2007, 12:05 AM
not only it is possible (http://www.google.com/search?hl=en&q=select+into+file), but it is also favorite feature abused by various exploits.
Mr Paul Jones
May 15th, 2007, 02:48 AM
Hmm sorry I guess this is important to say, but I would be terminating the SQL once a day via an automated batch file.
So instead of terminating the SQL each time a page loads, it would be limited to once a day.
Im not sure if this helps any of these exploits =/
Thanks
puppy
May 15th, 2007, 03:16 AM
it only makes it an exploit, if it can be exploited to overwrite arbitrary file on your site/host.
edit: i just re-read your post. if you are going to do it from your own machine, i guess there's nothing wrong with it.
foodpk
May 15th, 2007, 04:32 AM
You can do a cron job everyday and have it execute a PHP script which reads the SQL data, stores it as XML and then have a page that reads the XML. Or you could just store it delimited any way you want, depending on how complex your database is.
puppy
May 15th, 2007, 04:35 AM
but foodpk, what about clowns?
foodpk
May 15th, 2007, 04:46 AM
Well, no one really likes them actually, so they pretend to be happy while every one of them is a broken, empty shell of a man that he once was :)
puppy
May 15th, 2007, 05:24 AM
do u think haxors can abuse that shell for... liek, runnin sum sploit, or... do bad things?
Mr Paul Jones
June 8th, 2007, 01:51 PM
Will someone point me in the right direction here please lol
Been trying to work this out for ages now to no avail
Do I use something like EXPORT COLUMNS or INSERT INTO text file sorta thing
Thanks
Mr Paul Jones
June 19th, 2007, 03:50 AM
sorry to bump this but still not managed to do it
Mr Paul Jones
July 2nd, 2007, 05:40 PM
:(
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.