I want to convert the mysql database table contents to an Excel(.xls) or comma separated file(csv) using python script… Is it possible? Any one can help me?
Thanks in advance,
Nimmy
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
With third-party project mysqldb installed you can easily read that table, e.g:
You can of course write each row to a
csvfile with Python’s standard library csv module — you’ll just need animport csvat the start of your code. Then, after thecursor.execute, you can use code such as:If you want to write to an
.xlsfile instead of a.csv, see third-party module xlwt.