import pymysql

# 在这之前需要给mysql授登录权限 grant all on  "." to 'root'@'%' identified by "";   否则会导致连接时出错
# flush privileges;
#创建连接
conn = pymysql.connect(host='127.0.0.1',port=,user='root',passwd='',db='test') #创建游标
cursor = conn.cursor() #执行MySQL语句
SQL_core = "select * from student" # 执行MYSQL 并且返回影响行数
effect_row = cursor.execute(SQL_core)
print(effect_row) #取出数据的话 cursor.fetchone() cursor.fetchall()
print(cursor.fetchall()) data = [
(, 'c'),
(, 'd')
]
#data 两条数据一次性插入
cursor.executemany("insert into student (id, name) values(%s,%s)" ,data) #提交, 不然无法保存或者修改的数据
conn.commit() #g关闭数据连接
conn.close()

最新文章

  1. 50个新的汉化Demo!纯前端 Wijmo 放大招
  2. c# TimeSpan
  3. Delphi Berlin 10.1 for iOS 成生 info.plist 顺序改变了
  4. N900快捷键
  5. javaScript一些函数--Math()
  6. 黄聪:WordPress 多站点建站教程(五):获取子站点用户信息(通过输入站点ID号来获取该站点的所有用户)
  7. PHP函数补完:preg_match()
  8. JENKINS的远程API调用,然后用PYTHON解析出最新的版本及稳定成功的版本
  9. sqlserver编程基本语法
  10. Js-Html 前端系列--页面撑开头尾
  11. Java中的i=i++
  12. Python_ jiba、snownlp中文分词、pypinyin中文转拼音
  13. nginx warn an upstream response is buffered to a temporary file /var/cache/nginx/proxy_temp/ while reading upstream
  14. M - COURSES
  15. @Autowired Map<String , Object> xx
  16. 尚硅谷springboot学习19-日志切换
  17. [Docker] Getting Started with Container Networks
  18. AssetBundle中Unload()方法的作用
  19. 安装django 提示ImportError: No module named setuptools
  20. java中抽象类跟接口的区别

热门文章

  1. Linux文件属性(属主属组权限)
  2. 蓝牙压力測试报抛android.os.TransactionTooLargeException异常分析总结
  3. iOS9适配小结
  4. django admin显示多对多字段
  5. 图论之堆优化的Prim
  6. centos 服务器配置注意项
  7. ListView的setOnItemClickListener回调不能执行的解决
  8. <Sicily> 生成字符串
  9. echarts 总结:
  10. [洛谷P2245]星际导航