安裝MySQL
安裝MySQL不用多說了,下載下來安裝就是,沒有特別需要注意的地方。
一個下載地址:點擊打開鏈接
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62  | # coding=utf-8import MySQLdb#查詢數量def Count(cur):   count=cur.execute('select * from Student')    #插入def Insert(cur):   sql = "insert into Student(ID,Name,Age,Sex)values(%s,%s,%s,%s)"   param = (2,'xiaoming',24,'boy')   cur.execute(sql,param)#查詢 def  Select(cur):     n = cur.execute("select * from Student")       print "------"   for row in cur.fetchall():          for r in row:             print r      print "------"   #更新def Update(cur):   sql = "update Student set Name = %s where ID = 2"     param = ("xiaoxue")       count = cur.execute(sql,param)#刪除def Delete(cur):       sql = "delete from Student where Name = %s"     param =("xiaoxue")       n = cur.execute(sql,param)     try:   conn=MySQLdb.connect(host='localhost',user='root',passwd='123456',db='python',port=3306)   cur=conn.cursor()   #數量   Count(cur)   #查詢   Select(cur)   #插入   Insert(cur)   print "插入之后"   #查詢   Select(cur)   #更新   Update(cur)   print "更新之后"   #查詢   Select(cur)   #刪除   Delete(cur)   print "刪除之后"   #查詢   Select(cur)       cur.close()   conn.close()    except MySQLdb.Error,e:   print "Mysql Error %d: %s" % (e.args[0], e.args[1]) | 


新聞熱點
疑難解答