0
我试图把数据放入烧瓶使用和peewee的数据库,我也遇到了以下错误:peewee.OperationalError: no such table: post
peewee“没有这样的表”错误
我的models.py文件如下:
from peewee import *
import datetime
db = SqliteDatabase('posts.db') #create database to interact with
#create a class for blogposts
class Post(Model):
id = PrimaryKeyField()
date = DateTimeField(default = datetime.datetime.now)
title = CharField()
text = TextField()
class Meta:
database = db
def initialize_db():
db.connect()
db.create_tables([Post], safe = True)
db.close()
我已经谷歌搜索了这一点,并且对于大多数人来说,缺乏'db.create_tables()'似乎是问题所在。很明显,它在我的代码中,所以我不确定错误来自哪里。一些建议将不胜感激。当我尝试使用另一个.py文件填充“文本”字段时,问题似乎就会出现。