import MySQLdb
import csv
try:
conn=MySQLdb.connect(host='localhost',user='root',passwd='',db='abin',port=3306)
cursor=conn.cursor()
result = cursor.execute('select * from tabin')
info=cursor.fetchmany(result)
writer = csv.writer(file('your.csv','wb'))
writer.writerow(['id','name','time'])
for line in info:
writer.writerow(line)
except MySQLdb.Error,e:
print 'MySQLError is : ',e.args[0]