0
pythonスクリプトの実行中にエラーが発生しました。Python mysql.connectorエラー
ユーザーとパスワードを使用して直接確認しました。 ユーザーを保存してチェックし、変数も渡します。
スクリプト:
import mysql.connector,sys
try:
cnx = mysql.connector.connect (host='localhost', user = 'user', password = '[email protected]', port= 3306)
except mysql.connector.errors.ProgrammingError, e:
print time.strftime("%Y-%m-%d %H:%M:%S"),"Error %s" % (e)
sys.exit(1)
except mysql.connector.errors.InterfaceError, e1:
print time.strftime("%Y-%m-%d %H:%M:%S"),"Error %s" % (e1)
sys.exit(1)
cursor = db.cursor()
cursor.execute("select version()")
result_set = cursor.fetchall()
print result_set
エラー:
Traceback (most recent call last):
File "test.py", line 3, in <module>
cnx = mysql.connector.connect (host='localhost', user = 'user', password = '[email protected]', port= 3306)
AttributeError: 'str' object has no attribute 'connector'
あなたが掲示したコードの断片の上の任意の場所に変数名としてmysqlを使用していますか? –
いいえ、私は変数を使用しませんでした – Superstuff