O
O
ohaio ohaio2020-11-16 14:31:14
Python
ohaio ohaio, 2020-11-16 14:31:14

Peewee - sqlite - new data is not added, but overwrites the previous ones. What am I missing?

when adding records, I use standard methods:
MyModel.create(**source_data)
or
MyModel.insert(source_data).execute()
Data is not added, but overwrites the previous ones.
Almost all settings are default.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
v_b, 2020-11-16
@v_b

Didn't work with Peewee specifically, but is .commit() done after data is entered? It seems like here, by analogy, for example with SQLAlchemy, when entering new data, you need to commit: docs.peewee-orm.com/en/latest/peewee/api.html#Data...

_
_, 2020-11-16
@mrxor

Most likely, your records have the same primary key - that's why it is overwritten.
Show the model and what's in source_data.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question