我正在尝试在MySQL中使用此命令创建一个表:
CREATE TABLE tutorial_info(
tutorial_id INT NOT_NULL AUTO_INCREMENT PRIMARY KEY,
tutorial_title VARCHAR(100) NOT_NULL,
tutorial_author VARCHAR(100) NOT_NULL,
submission_date TIMESTAMP
);
我只是将代码剪切并粘贴到终端中,但我收到错误:
您的SQL语法出错;查看与您的MySQL服务器版本相对应的手册,以便在'NOT_NULL AUTO_INCREMENT PRIMARY KEY,tutorial_title VARCHAR(100)NOT_NULL'附近使用正确的语法,在第1行
不确定这里发生了什么。有人能给我一个指针,指出我在这里做错了吗?感谢
答案 0 :(得分:2)
将def parse_site(self, response):
item = response.meta['item']
item['websites'] = response.xpath("//div[@class='company-contact-information']/table/tr/td/a/@href").extract()
item['websites'] = self.remove_blacklist_links(item['websites'])
# item['websites'] = ['http://www.kai-hsiang.com.tw','http://www.yangshitex.com']
print(item['websites'])
time.sleep(1)
for web in item['websites']:
request = scrapy.Request(web, callback=self.get_emails, dont_filter=True)
print(web)
print(request)
time.sleep(2)
yield request
def get_emails(self, response):
# the_leads = []
item = response.meta['item']
for l in response.xpath('//a'):
link = l.xpath('@href').extract()[0]
print(link)
ju = urlparse.urljoin(response.url, link)
# the_leads.append(self.extract_email) --> Just added this now to explain what is
# possible if not for the request and yield
request = scrapy.Request(ju, callback=self.extract_emails, dont_filter=True, meta={'item': item}) # ---> How do i get a return value for extract_emails ?
print(response.url, ju, link, "*" * 100)
yield request
# item['emails'] = all_leads
# return item
def extract_emails(self, response):
item = response.meta['item']
regex = re.compile(r'([\w\-\.]{1,100}@(\w[\w\-]+\.)+[\w\-]+)')
emails = list(set(regex.findall(response.body)))
all_emails = [email[0].lower() for email in emails]
item['emails'] = all_emails
# print(item)
# print("*" * 20)
return item # this overrites the emails
更改为NOT_NULL
:
NOT NULL
答案 1 :(得分:1)
如果没有_
CREATE TABLE tutorial_info(
tutorial_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
tutorial_title VARCHAR(100) NOT NULL,
tutorial_author VARCHAR(100) NOT NULL,
submission_date TIMESTAMP
);