Structured Query Language
SQL是结构化查询语言,是一种用来操作RDBMS的数据库语言,当前关系型数据库都支持使用SQL语言进行操作,也就是说可以通过 SQL 操作 oracle,sql server,mysql,sqlite 等等所有的关系型的数据库
# 创建Connection连接
conn = connect(host=‘localhost‘, port=3306, user=‘root‘, password=‘mysql‘, database=‘python1‘, charset=‘utf8‘)
# 得Cursor对象
cs = conn.cursor()
# 更新
# sql = ‘update students set name="刘邦" where id=6‘
# 删除
# sql = ‘delete from students where id=6‘
# 执行select语句,并返回受影响的行数:查询一条学生数据
sql = ‘select id,name from students where id = 7‘
# sql = ‘SELECT id,name FROM students WHERE id = 7‘
count=cs.execute(sql)
# 打印受影响的行数
print(count)
原文:https://www.cnblogs.com/jyue/p/10481137.html