課程
/后端開發(fā)
/Python
/python遇見數(shù)據(jù)采集
可以成功連接數(shù)據(jù)庫為什么每次都只有一條數(shù)據(jù),最后的那一條,disclaimers這條
2018-04-09
源自:python遇見數(shù)據(jù)采集 4-1
正在回答
import MySQLdb
db = MySQLdb.connect("localhost","root","123456","wyj",charset='utf8')
cursor = db.cursor()
sql = "select * from tabtest"
cursor.execute(sql)
data = cursor.fetchall()
讀取到的數(shù)據(jù)都存在data中,只要多data進(jìn)行循環(huán)就可以看到所有數(shù)據(jù)
希望能幫到你
舉報(bào)
本教程讓你初步掌握Python進(jìn)行數(shù)據(jù)采集,創(chuàng)造屬于你的價(jià)值
9 回答腳本可以執(zhí)行成功,數(shù)據(jù)庫只有一條數(shù)據(jù),這是為什么?
2 回答插入mysql數(shù)據(jù)庫只有一條數(shù)據(jù)?
1 回答在循環(huán)里生成數(shù)據(jù)庫連接,每一個(gè)元素都會(huì)產(chǎn)生一個(gè)這個(gè)沒有問題么?
2 回答有14條數(shù)據(jù),然后報(bào)了‘pymysql.err.Error: Already closed’這個(gè)錯(cuò)誤
1 回答 # 獲取數(shù)據(jù)庫連接connection報(bào)錯(cuò)
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2018-04-11
import MySQLdb
db = MySQLdb.connect("localhost","root","123456","wyj",charset='utf8')
cursor = db.cursor()
sql = "select * from tabtest"
cursor.execute(sql)
data = cursor.fetchall()
讀取到的數(shù)據(jù)都存在data中,只要多data進(jìn)行循環(huán)就可以看到所有數(shù)據(jù)
希望能幫到你