日日操夜夜添-日日操影院-日日草夜夜操-日日干干-精品一区二区三区波多野结衣-精品一区二区三区高清免费不卡

公告:魔扣目錄網(wǎng)為廣大站長提供免費收錄網(wǎng)站服務(wù),提交前請做好本站友鏈:【 網(wǎng)站目錄:http://www.ylptlb.cn 】, 免友鏈快審服務(wù)(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網(wǎng)站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

本文介紹了屬性錯誤:模塊'MySQL'沒有屬性'連接器'的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在運行MacOS Mojave,試圖通過Spyder ide(Python3)使用MySQL-python連接器連接到MySQL

但我收到錯誤:

File "/Users/admin/Desktop/omgboi.py", line 5, in <module>
    mydb=mysql.connector.connect(host='localhost',user='root',passwd='hariom21feb',database='test')

AttributeError: module 'mysql' has no attribute 'connector'

我嘗試通過bash安裝和重新安裝MySQL-Connector和MySQL-Connector-python,但不起作用。我還嘗試更改了文件的名稱,但效果不佳。代碼如下:

import mysql.connector
import random
first_names=['Jodee,Marielle,Phillip,Colby,Stephany,Dione,Grover,Napoleon,Nicholas,Alysa,Noma,Leta,Ciera,Donny,Buc,Iren,Renato,Glory,Stacia,Bennie,Soo,Mitzie,Kaci,Peggy,Hilma,Melva,Cindie,Miyoko,Melina,Cammy,Blanche,Rhea,Jill,Kellye,Ailene,Vida,Alva,Sau,Hollis,Oswaldo,Marty']
last_names=['Bula,Bibi,Rolf,Tayna,Ardith,Art,Jeannetta,Patrina,Ronny,Maida,Cleopatra,Sherry,Vincenza,Sheri,Sherlyn,Shayne,Geneva,Javier,Celine,Saran,Shari,Boris,Gwyneth,Summer,Maryellen,Rufina,Essie,Palma,Rafael,Cordell,Jude,Jenine,Manuel,Cleveland,Daphine,Lavina,Candi,Rossie,Brunilda,Gilberte,Nick,Hoyt,Lucius,Ardis,Tyler,Dwain,Caleb,Aide,Mckinley,Margurite']
mydb=mysql.connector.connect(host='localhost',user='root',passwd='hariom21feb',database='test')
mycursor=mydb.cursor()
fkey=random.randint(0,49)
lkey=random.randint(0,49)
nkey=random.randint(0,50)
for i in range(nkey):
    query=('insert into test value(%s,%s,%s,%s,%s)')
    tup=('L5W4NW',first_names(fkey),last_names(lkey),'2970','completed')
    mycursor.execute(query,tup)
mydb.commit()

知道我做錯了什么嗎?

推薦答案

您是如何安裝的?

PyPI包mysql-connector已棄用,應(yīng)使用官方mysql-connector-python。

最簡單也是最推薦的方法是使用pip

pip install mysql-connector-python

有關(guān)安裝的詳細(xì)信息,請點擊此處https://dev.mysql.com/doc/dev/connector-python/8.0/installation.html

這篇關(guān)于屬性錯誤:模塊&#39;MySQL&#39;沒有屬性&#39;連接器&#39;的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,

分享到:
標(biāo)簽:errorAttributeerror:module'mysql'hasnoattribute'connector&
用戶無頭像

網(wǎng)友整理

注冊時間:

網(wǎng)站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網(wǎng)站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網(wǎng)站吧!
最新入駐小程序

數(shù)獨大挑戰(zhàn)2018-06-03

數(shù)獨一種數(shù)學(xué)游戲,玩家需要根據(jù)9

答題星2018-06-03

您可以通過答題星輕松地創(chuàng)建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學(xué)四六

運動步數(shù)有氧達(dá)人2018-06-03

記錄運動步數(shù),積累氧氣值。還可偷

每日養(yǎng)生app2018-06-03

每日養(yǎng)生,天天健康

體育訓(xùn)練成績評定2018-06-03

通用課目體育訓(xùn)練成績評定