D
D
Dmitry Shelygin2019-12-14 14:34:37
css
Dmitry Shelygin, 2019-12-14 14:34:37

Why doesn't peewee save changes?

Peewee, for some unknown reason, stopped updating records in the database

user = User.get(User.telegram_id == telegram_id)
user.state = json.dumps({
            'action': 'create',
            'step': 'name',
            'type': 'Categories',
            'value': None
        })
user.save()

The next time this user is retrieved from the database, the state field will be NULL.
If add force_insert=True
user = User.get(User.telegram_id == telegram_id)
user.state = json.dumps({
            'action': 'create',
            'step': 'name',
            'type': 'Categories',
            'value': None
        })
user.save(force_insert=True)

it crashes with an error
peewee.IntegrityError: (1062, "Duplicate entry '1' for key 'PRIMARY'")

This option:
state = json.dumps({
            'action': 'create',
            'step': 'name',
            'type': 'Categories',
            'value': None
        })
query = User.update({User.state: state}).where(User.telegram_id == telegram_id)
query.execute()

doesn't record either.
Although in debug mode, if you look, then in the user the value of state changes. But not in the database itself!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Rustam Bainazarov, 2019-01-26
@yaNastia

Flex (for better and easier browser support) + box-shadow (to keep the box size small; can be replaced with a pseudo-element):

R
Ruslan Malkhozov, 2019-01-26
@bybon4uk

More or less like this?

D
Dmitry Shelygin, 2019-12-14
@JustJew

The most interesting thing is that it worked before and suddenly stopped working.
I noticed this after I decided to change the program for viewing SQLite files.
After opening the database in another program, when executing the code, I received an error that the database was already in use.
Changed DBMS to MySQL. Now everything works, but the existing records in the database are not updated.
New ones are created and old ones are NOT overwritten.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question