創(chuàng)新互聯(lián)www.cdcxhl.cn八線動態(tài)BGP香港云服務(wù)器提供商,新人活動買多久送多久,劃算不套路!
這篇文章主要介紹python中mysql語句怎么寫,文中示例代碼介紹的非常詳細(xì),具有一定的參考價值,感興趣的小伙伴們一定要看完!
python中mysql語句:
1、刪除語句,根據(jù)條件刪除數(shù)據(jù)
def DeleteInventory(self,Delete_goodsID): DeleteInventory_sql=("DELETE FROM inventoryinformation WHERE goodsID= %s") asd = self.conn.execute(DeleteInventory_sql,Delete_goodsID) return asd
這里 用 %s 代替了傳入的參數(shù) Delete_goodsID 然后用其父類BaseBusiness 里面的 execute 方法,來執(zhí)行SQL語句
2、修改語句,根據(jù)條件修改數(shù)據(jù)
manager_sql=("update manager set managerPassword= %s where managerID= %s ")
3、查詢語句,根據(jù)條件查詢所需的數(shù)據(jù)
select_sql=("select managerID,managerPassword from manager where managerID= %s and managerPassword= %s ")
4、添加語句,根據(jù)條件添加數(shù)據(jù)
sql=("INSERT INTO customer(customerID,customerName,customerAddress,customerBankAccount,customerPayee,""customerAccountNumber,customerContacts,companyTelephone,contactPhone,customerFax) VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)")
這樣,基本的增刪改查都有了,而且SQL語句中因為是傳入的參數(shù),可以避免一些SQL注入問題,還是比較好的
以上是python中mysql語句怎么寫的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)-成都網(wǎng)站建設(shè)公司行業(yè)資訊頻道!
標(biāo)題名稱:關(guān)于python中mysql語句的寫法-創(chuàng)新互聯(lián)
分享路徑:http://chinadenli.net/article48/cdjihp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供動態(tài)網(wǎng)站、網(wǎng)站策劃、服務(wù)器托管、網(wǎng)站維護、App設(shè)計、企業(yè)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容