Peewee (Python Sqlite ORM) - NameError: name 'SqliteDatabase' is not defined

Peewee (Python Sqlite ORM) - NameError: name 'SqliteDatabase' is not defined

OS Linux Mint 18.3(但版本 19 也有同样的问题)
Python3 并安装了 Sqlite3

在 "pip / pip3" 遇到很多麻烦之后,我设法安装了 Peewee

我用 python3 peewee.py 尝试 运行 以下示例脚本,但出现此错误:

脚本 (peewee.py)

from peewee import *

db = SqliteDatabase("people.db")

class Person(Model):
    name = CharField()
    birthday = DateField()

    class Meta:
        database = db # This model uses the "people.db" database.

class Pet(Model):
    owner = ForeignKeyField(Person, backref='pets')
    name = CharField()
    animal_type = CharField()

    class Meta:
        database = db # this model uses the "people.db" database

db.connect()

错误

Traceback (most recent call last):
  File "peewee.py", line 3, in <module>
    from peewee import *
  File "/home/.../peewee.py", line 6, in <module>
    db = SqliteDatabase("people.db")
NameError: name 'SqliteDatabase' is not defined

我已经对 google / Whosebug 进行了广泛的研究,但我无法解决这个问题。你能帮帮我吗?

我尝试了不同的方法来解决这个问题...结果发现这个问题与 peewee 无关,而是 python。

我将脚本文件命名为peewee.py。

因此,由于脚本的第一行 from peewee import *,Python 导入了我自己的脚本而不是真正的 peewee 包,因此出现错误。

解决方案
将脚本文件重命名为其他名称。

(评论:...很伤心...因为一个愚蠢的新手错误浪费了很多时间)

来源:
Python AttributeError: 'module' object has no attribute 'connect'