日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:用python如何導出數(shù)據(jù)庫數(shù)據(jù)

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

使用“import”命令導入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ù)就可以導出數(shù)據(jù)庫數(shù)據(jù)了

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

更多Python知識,請關注:Python自學網(wǎng)?。?/p>
新聞標題:創(chuàng)新互聯(lián)Python教程:用python如何導出數(shù)據(jù)庫數(shù)據(jù)
本文地址:http://m.5511xx.com/article/djsigsj.html