这是一个创建于 1527 天前的主题,其中的信息可能已经有所发展或是发生改变。
import requests
from bs4 import BeautifulSoup
import re
import json
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Integer, String
from sqlalchemy.orm import sessionmaker
engine = create_engine('sqlite:///notice_hyzhdj.db?check_same_thread=False', echo=True)
Base = declarative_base()
class Notice(Base):
__tablename__ = 'notice'
id = Column(Integer, primary_key=True, autoincrement=True)
title = Column(String(100))
src = Column(String(100))
date = Column(String(32))
def __init__(self, title, src, date):
self.title = title
self.src = src
self.date = date
Base.metadata.creat_all(engine)
运行报错
AttributeError: 'MetaData' object has no attribute 'creat_all'
我按照实例敲的,百度也没找到这个错误的原因,求各位大佬指点下
sqlalchemy 版本是 1.3.19
3 条回复 • 2020-08-29 21:20:19 +08:00
|
|
1
j0hnj 2020-08-28 11:31:52 +08:00
creat_all => create_all
|
|
|
3
efaun 2020-08-29 21:20:19 +08:00
你需要用 pycharm
|