学习笔记 ,仅供参考

1、运行Python解释器

[email protected]:~$ python


2、导入MySQLdb模块

>>> import MySQLdb


3、数据库的三步操作,连接、发送SQL指令、退出。

conn = MySQLdb.connect(".........")  连接

cur = conn.cursor()        创建游标

conn.select_db("库名")       连接到库

cur.execute(SQL指令)        执行SQL指令

conn.commit()    执行此语句后 数据才提交到数据库

cur.close()

conn.close() 退出


Python 的 mysql 操作

相关文章:

  • 2022-01-17
  • 2021-11-03
猜你喜欢
  • 2021-07-25
  • 2021-11-09
  • 2022-12-23
  • 2022-01-01
  • 2021-08-21
  • 2021-05-25
相关资源
相似解决方案