程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Python tutorial 97 -- MySQL operation of Python database

編輯:Python

Database operations generally refer to adding, deleting, modifying, and querying .

1、 Create a table in the database :

2、Python MySQL Insert  (Python MySQL insert) 

3、Python MySQL choice  (Python MySQL select) 

Other codes are as follows :

# Python MySQL to update (Python MySQL update)
updateSql = "UPDATE Artists SET NAME= 'Tauwang' WHERE ID = '1' ;"
cursor.execute(updateSql)
# Python MySQL Delete (Python MySQL delete)
deleteSql = "DELETE FROM Artists WHERE ID = '1'; "
cursor.execute(deleteSql )
# Python MySQL Example – Delete table (Python MySQL Example – Drop Table)
dropSql = "DROP TABLE IF EXISTS Artists;"
cursor.execute(dropSql)

  The above is Python Yes mysql Basic operation of database .


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved