import csv
import os
import pymysql
from pprint import pprint
# import pandas
class Test_myqsl(object):
def __init__(self):
#读取数据库和建立游标对象
self.connect = pymysql.connect(host="127.0.0.1",
port=3306,
user="root",
password="password",
database="databases",
charset="utf8")
self.cursor = self.connect.cursor(cursor=pymysql.cursors.DictCursor)
# 关闭数据库和游标对象
def __del__(self):
self.connect.close()
self.cursor.close()
def write(self):
file = 'code.csv'
productID = ['id','list_1','list_1','list_1','list_1','list_1']
rows = self.read()
with open(file, "
如何读取数据库并把数据导出CSV文档
最新推荐文章于 2022-08-09 22:40:21 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)