简体   繁体   English

OperationalError:(pymysql.err.OperationalError)(1045,运行蜘蛛脚本时“用户访问被拒绝”

[英]OperationalError: (pymysql.err.OperationalError) (1045, "Access denied for user” when run spider script

I use anconda and python 3.7 in Windows 7. I have write a spider script.我在 Windows 7 中使用 anconda 和 python 3.7。我写了一个蜘蛛脚本。

But when I tried to run it, error occurs: (using password: NO)")但是当我尝试运行它时,出现了错误:(using password: NO)")

It seems like the error is from system file and not my script, so I do not know how to fix it.似乎错误来自系统文件而不是我的脚本,所以我不知道如何修复它。

import pandas as pd
from bs4 import BeautifulSoup
import sqlalchemy
from sqlalchemy import create_engine


path = 'd:/data/app_qcc512x_qcc302x.html'
htmlfile = open(path, 'r', encoding='utf-8')

htmlhandle = htmlfile.read()


soup = BeautifulSoup(htmlhandle, 'lxml')




count = 0
result = pd.DataFrame({},index=[0])
result['author'] = ''
result['title'] = ''
result['source'] = ''
new = result
for item in soup.find_all('tr'):
if 'AU ' in item.get_text():
    author = item.get_text()
    new['author'] = author
elif 'TI ' in item.get_text():
    title = item.get_text()
    new['title'] = title
elif 'SO ' in item.get_text():
    source = item.get_text()
    new['source'] = source
    count += 1
    result = result.append(new,ignore_index=True)
print(count)


connect_info = 'mysql+pymysql://{}:{}@{}:{}/{}? 
charset=utf8'.format("username", "password", "host", "port", "qcc")
engine = create_engine(connect_info)

df.to_sql(name='app_qcc512x_qcc302x',
      con=engine,
      if_exists='append',
      index=False,
      dtype={'IterationId': sqlalchemy.types.Integer(),
             'title': sqlalchemy.types.NVARCHAR(length=255)
             }
           )

error:错误:

OperationalError: (pymysql.err.OperationalError) (1045, "Access denied for 
user”
(using password: NO)")

I had not added DB_USER=xyz to the env file.我没有将DB_USER=xyz添加到 env 文件中。 I checked it with echo $DB_USER and found that the environment variable was empty.我用echo $DB_USER查看了一下,发现环境变量是空的。 It then threw the same error:然后它抛出了同样的错误:

sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (1045, "Access denied for user 'xyz@MY_HOST' (using password: NO)")

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 pymysql.err.OperationalError: (1045, “访问被拒绝用户 'MYID'@'localhost'(使用密码:NO)”) - pymysql.err.OperationalError: (1045, “Access denied for user 'MYID'@'localhost' (using password: NO)”) Python/Masonite:pymysql.err.OperationalError(1045,“用户 'root'@'172.18.0.1' 的访问被拒绝(使用密码:YES)”) - Python/Masonite: pymysql.err.OperationalError (1045, "Access denied for user 'root'@'172.18.0.1' (using password: YES)") python不连接mysql。 pymysql.err.OperationalError:(1045,“用户'root'@'localhost'的访问被拒绝(使用密码:NO)”) - python doesn't connect mysql. pymysql.err.OperationalError: (1045, “Access denied for user 'root'@'localhost' (using password: NO)”) sqlalchemy OperationalError: (OperationalError) (1045, "Access denied for user - sqlalchemy OperationalError: (OperationalError) (1045, "Access denied for user pymysql.err.OperationalError - 查询期间丢失与 MySQL 服务器的连接 - pymysql.err.OperationalError - Lost connection to MySQL server during query sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query') - sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query') OperationalError:(1045,“拒绝用户'root'@'localhost'的访问(使用密码:是)”) - OperationalError: (1045, “Access denied for user 'root'@'localhost' (using password: YES)”) Python MySQL OperationalError:1045,“访问被拒绝用户root @'localhost' - Python MySQL OperationalError: 1045, "Access denied for user root@'localhost' 无法在Google CloudSQL OperationalError 1045上运行syncdb,使用密码:用户'root'@'localhost'拒绝访问 - Can't run syncdb on Google CloudSQL OperationalError 1045 Access denied for user 'root'@'localhost' using password: NO _mysql_exceptions.OperationalError:1045,“用户的访问被拒绝 - _mysql_exceptions.OperationalError: 1045, "Access denied for user
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM