微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

由于secure_file_priv,无法将表导出到输出文件中

如何解决由于secure_file_priv,无法将表导出到输出文件中

我使用的是 windows7 和 MysqL8.0。我试图通过先停止服务来编辑 my.ini。首先,如果我试图用 secure_file_priv = "" 替换 my.ini,它说访问被拒绝。所以,我只是用“my1.ini”保存它然后删除了my.ini并再次将“my1.ini”重命名为“my.ini”。现在,当我尝试从管理工具>服务启动 MysqL80 服务时,我无法再次启动它。即使我已经从 CLI 客户端尝试过这个,但它引发了 secure_file_priv 的问题。我该怎么做?我已经能够使用 Scrapy 将抓取的数据存储到 MysqL 数据库中,但无法将其导出到我的项目目录中。

#pipelines.py

from itemadapter import ItemAdapter
import MysqL.connector

class QuotewebcrawlerPipeline(object):

    def __init__(self):
        self.create_connection()
        self.create_table()
        #self.dump_database()

    def create_connection(self):
        """
            This method will create the database connection & the cusror object
        """
        self.conn = MysqL.connector.connect(host = 'localhost',user = 'root',passwd = 'Pxxxx',database = 'itemcontainer'
                                        )
        self.cursor = self.conn.cursor()
    
    def create_table(self):
        self.cursor.execute(""" DROP TABLE IF EXISTS my_table""")
        self.cursor.execute(""" CREATE TABLE my_table (
                                Quote text,Author text,Tag text)"""
                            )

    def process_item(self,item,spider):
        #print(item['quote'])
        self.store_db(item)
        return item

    def store_db(self,item):
        """
            This method is used to write the scraped data from item container into the database
        """
        #pass
        self.cursor.execute(""" INSERT INTO my_table VALUES(%s,%s,%s)""",(item['quote'][0],item['author'][0],item['tag'][0])
                            )
        self.conn.commit()
        #self.dump_database()

    # def dump_database(self):
    #     self.cursor.execute("""USE itemcontainer;SELECT * from my_table INTO OUTFILE 'quotes.txt'""",#                         multi = True
    #     )
    #     print("Data saved to output file")

#item_container.py

import scrapy
from ..items import QuotewebcrawlerItem

class ItemContainer(scrapy.Spider):

name = 'itemcontainer'
start_urls = [
    "http://quotes.toscrape.com/"
]

def parse(self,response):

    items = QuotewebcrawlerItem()
    all_div_quotes = response.css("div.quote")
    for quotes in all_div_quotes:
        quote = quotes.css(".text::text").extract()
        author = quotes.css(".author::text").extract()
        tag = quotes.css(".tag::text").extract()

        items['quote'] = quote
        items['author'] = author
        items['tag'] = tag
        
        yield items

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?