#读取
方式一:(元组嵌套格式)
1 | db=pymysql.connect(host='localhost',port=3306,user='root',database='comp',password='123456',charset='utf8mb4') |
方式二:(dataframe格式)
1 | conn=pymysql.connect(host='localhost',port=3306,user='root',database='comp',password='123456',charset='utf8mb4') |
方式三:(dataframe格式)
1 | from sqlalchemy import create_engine |
#存储
方式一:直接dataframe保存到mysql
1 | from sqlalchemy import create_engine |
###方式二:正常存储1
2
3
4
5
6
7
8
9db = pymysql.connect(host='localhost', port=3306, user='root',database='comp',password='123456',
charset='utf8mb4')
cursor = db.cursor()
data = (data[0], data[1])
sql = 'insert into patent_apply_date (app_text,apply_msg) values (%s,%s)'
cursor.execute(sql, data)
db.commit()
cursor.close()
db.close()