Peewee ORM 为列插入空白值

问题描述 投票:0回答:0

我一直在尝试使用 peewee orm 为我的项目将值插入数据库,问题是它似乎没有理由地为其中一列插入空白值,我有一个 for 循环插入这些值并且它只忽略url 值,这是我的模型:

class RawUrl(BaseModel):

    class Meta:
        table_name = "raw_urls"
        collation = "utf8mb4_unicode_ci"
    
    url      = pw.CharField(max_length=255, null=False)
    source   = pw.ForeignKeyField(Source, backref="url_source")
    added_on = pw.DateTimeField(default=datetime.now)

我尝试使用 get_or_create、.create,甚至只是将对象分配给一个变量并保存它,但由于某种原因它总是使 url 字段为空。我在 ubuntu 20.04 上使用 MySQL 5.7 作为数据库

python python-3.x peewee flask-peewee
© www.soinside.com 2019 - 2024. All rights reserved.