新聞中心
這篇文章主要介紹python中MySQL語句怎么寫,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!
成都創(chuàng)新互聯(lián)公司是一家集網(wǎng)站建設(shè),鹿泉企業(yè)網(wǎng)站建設(shè),鹿泉品牌網(wǎng)站建設(shè),網(wǎng)站定制,鹿泉網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,鹿泉網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競爭力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。
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語句中因?yàn)槭莻魅氲膮?shù),可以避免一些SQL注入問題,還是比較好的
以上是python中mysql語句怎么寫的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對大家有幫助,更多相關(guān)知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!
網(wǎng)站標(biāo)題:關(guān)于python中mysql語句的寫法
轉(zhuǎn)載注明:http://fisionsoft.com.cn/article/ghissd.html