Forums

MySQL load data in file

Hi! I'm quite new in Python and MySQL and I need a help. I can't load data from mySQL table into a file, every time I'm trying to do it I get ERROR 1045 (2800) Access denied etc. I've read this topic http://help.pythonanywhere.com/pages/LoadDataInfile and connected mysql database manually and then I was trying to type: SELECT * FROM luft_oppdatering INTO OUTFILE '/home/sHalnes/file.txt'; but I've got the same error 1045(2800). So what should I do to save data from mysql into a .txt file?

This Stack Overflow post explain how to get the effect you want.

A brief explanation of what's going on -- with MySQL, you have to think in terms of two machines. There's the client machine where you're running the mysql client program (typically one of our console servers) and there's the MySQL server machine. On the client machine, you have access to your PythonAnywhere file storage. But the MySQL server doesn't know anything about your file storage. But the "INTO OUTFILE" syntax is designed to write stuff to disk on the MySQL server, so it doesn't work.

Thank you for the answer. Now I have idea how does it work. Unfortunately this StackOverflow post didn't help me much, but I solved my problem anyway, just had to write a small python script.

can I know what script you wrote to do that

can I know what script you wrote to do that