av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

創(chuàng)新互聯(lián)Python教程:用python如何導(dǎo)出數(shù)據(jù)庫數(shù)據(jù)

用python導(dǎo)出數(shù)據(jù)庫數(shù)據(jù)的方法:

使用“import”命令導(dǎo)入pymysql模塊

import pymysql

用connect函數(shù)連接數(shù)據(jù)庫,實例化連接對象,調(diào)用execute函數(shù)將sql語句映射到數(shù)據(jù)庫中

host, user, passwd, db='127.0.0.1','root','123','xxx'
    conn = pymysql.connect(user=user,host=host,port=3306,passwd=passwd,db=db,charset='utf8')
cur = conn.cursor()
   
sql = 'select * from %s' % table_name
    
cur.execute(sql)  # 返回受影響的行數(shù)

使用fetchall函數(shù)就可以導(dǎo)出數(shù)據(jù)庫數(shù)據(jù)了

fields = [field[0] for field in cur.description]  # 獲取所有字段名
    
all_data = cur.fetchall()  # 所有數(shù)據(jù)

更多Python知識,請關(guān)注:Python自學(xué)網(wǎng)??!


當(dāng)前文章:創(chuàng)新互聯(lián)Python教程:用python如何導(dǎo)出數(shù)據(jù)庫數(shù)據(jù)
文章轉(zhuǎn)載:http://uogjgqi.cn/article/djsigsj.html
掃二維碼與項目經(jīng)理溝通

我們在微信上24小時期待你的聲音

解答本文疑問/技術(shù)咨詢/運(yùn)營咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流