Closed PhilippCh closed 2 months ago
You are using :
instead of =
:)
Try
import datetime
from peewee import Model, TextField, BooleanField, DateTimeField
from playhouse.shortcuts import model_to_dict
from playhouse.sqlite_ext import SqliteExtDatabase
db = SqliteExtDatabase('shoppr.db', pragmas={
'journal_mode': 'wal', # WAL-mode.
'cache_size': -64 * 1000, # 64MB cache.
'synchronous': 0})
class Task(Model):
title = TextField()
description = TextField()
createdAt = DateTimeField(default=datetime.datetime.now)
changedAt = DateTimeField(default=datetime.datetime.now)
isDone = BooleanField(default=False)
class Meta:
database = db
db.connect()
db.create_tables([Task])
This gives me
Oh wow, thanks a lot... like I said, still getting used to python 😀
Hi there!
New to python in general, so please excuse it if I'm doing something wrong, but I cannot figure out why
create_tables([Task])
does not create the fields that I provided for theTask
class.All that is created from this in the SQLite db is the id column:
When debugging into
create_tables()
, it appears that the model is missing some fields (title, description, isDone) while others (createdAt, changedAt) are present, but not created in the DB.Is there anything I'm doing wrong? Your help would be greatly appreciated!