Mysql笔记

pymysql的使用:

import pymysql.cursors
#连接配置信息
config = {
'host':'127.0.0.1',
'port':3306,
'user':'root',
'password':'2778142138',
'db':'NER',
'charset':'utf8',
'cursorclass':pymysql.cursors.DictCursor,
}
# 创建连接
connection = pymysql.connect(**config)
cursor = connection.cursor()
sql = "INSERT INTO sentence_table (name, sentence) VALUES ('%s', '%s')"%(company_name,sentence)

print(sentence)
cursor.execute(sql)
connection.commit()

truncate table table_name;  清空表
delete * from table_name;  删除表
 



posted @ 2019-05-16 15:25  慕云深  阅读(194)  评论(0编辑  收藏  举报