Page 69 - Python Cơ Bản
P. 69

import MySQLdb



           db = MySQLdb.connect(...)

           cursor = db.cursor()

           cursor.close()

           db.close()





               4VITEVIH 7XEXIQIRX






          4VITEVIH WXEXIQIRX Pɧ Oц XLYϼX XLEQ WР LɹE GɨG Hо PMЖY


          XVY]АR ZɧS GɩY XVY] ZϴR XLE] Zɳ RРM GLYЦM XVрG XMЎT чВ \ɩ]

          HрRK QШX GLYЦM XVY] ZϴR HɧM  /ц XLYϼX Rɧ] чšвG ɨT HдRK


          RLMАY Zɧ KMɾT XʆRK LMЖY UYϲ Zɧ XɴRL FϲS QϼX GжE GɩY XVY]


          ZϴR  :ɴ Hд






           ...
           cur.execute("UPDATE Writers SET Name = %s WHERE Id


           = %s", ("John", "4"))
           ...






          1ЦM XLEQ WР XVY] ZϴR WЌ чšвG XLE] XLЎ FЀRK  %s  Zɧ TLš˜RK


          XLиG  execute()  WЌ Gɹ XLEQ WР XLи   Pɧ QШX 8YTPI Gɹ KMɨ XVК
   64   65   66   67   68   69   70   71   72   73   74