Answer the question
In order to leave comments, you need to log in
How to add unique records to the database, but only for the date that is not yet in the database?
I'm starting to practice with databases, and decided to use the peewee ORM. For training, I decided to create a table with expense records and fields: purchase date, product name (unique field), product price.
The model looks like this:
class BaseModel(Model):
class Meta:
database = db
class Purchases(BaseModel):
purchase_day = CharField()
product = CharField(unique=True)
price = FloatField()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question