2
我有以下代碼PeeWee ORM報告說表已經存在
db = peewee.SqliteDatabase(":memory:")
class CategoryProduct(peewee.Model):
category_code = peewee.CharField()
product_code = peewee.CharField()
product_order = peewee.CharField()
default_category = peewee.CharField()
def __str__(self):
return "({0}, {1})".format(self.category_code, self.product_code)
db.connect()
db.create_tables([CategoryProduct])
當我運行該腳本,我得到
('CREATE TABLE "categoryproduct" ("id" INTEGER NOT NULL PRIMARY KEY, "category_code" VARCHAR(255) NOT NULL, "product_code" VARCHAR(255) NOT NULL, "product_order" VARCHAR(255) NOT NULL, "default_category" VARCHAR(255) NOT NULL)', [])
Traceback (most recent call last):
File "/Users/daniels/Work/sandbox/venv/lib/python3.5/site-packages/peewee.py", line 3676, in execute_sql
cursor.execute(sql, params or())
sqlite3.OperationalError: table "categoryproduct" already exists
任何想法是怎麼回事?如果我創建任何其他模塊它工作正常,但不知何故它不喜歡這個名字。
噢,夥計...的複製和粘貼的問題...忘了還複製了「類元」 ......我真希望啓用調試模式也將顯示每個模型試圖使用的數據庫。本來更容易調試。 – daniels