Return to Snippet

Revision: 11514
at February 8, 2009 10:46 by vasilije


Initial Code
SELECTQ="SELECT * FROM category"
FILENAME="dump.csv"

import MySQLdb
import csv

db = MySQLdb.connect(host="localhost", user="root", passwd="", db="sakila")
dump_writer = csv.writer(open(FILENAME,'w'), delimiter=',',quotechar="'")
cursor = db.cursor()
cursor.execute(SELECTQ)
result = cursor.fetchall()
for record in result:
    dump_writer.writerow(record)
    
db.close()

Initial URL

                                

Initial Description

                                

Initial Title
Simple csv dump script

Initial Tags
mysql, python

Initial Language
Python