question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`get_or_create` not working for sqlite/postgresql

See original GitHub issue

Describe the bug user, _ = await User.get_or_create(id=ctx.author.id) for sqlite/postgresql just awaits eternally, no user is created in database

To Reproduce

  • can’t create user via User.get_or_create
  • code after await is never execute (aka awaited eternally)

Expected behavior

  • user should be created

Additional context

class User(Model):
    """User table"""

    id = fields.IntField(pk=True)
    balance = fields.data.DecimalField(max_digits=15, decimal_places=2, default=0)
    created_at = fields.DatetimeField(auto_now_add=True)
    modified_at = fields.DatetimeField(auto_now=True)

    def __str__(self):
        return f"#{self.id}"

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
long2icecommented, Mar 27, 2021

Fixed

0reactions
long2icecommented, Mar 27, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

Write a Postgres Get or Create SQL Query - Stack Overflow
INSERT INTO mytable (color, brightness, size, age) SELECT color, brightness, size, age FROM mytable WHERE NOT EXISTS ( SELECT 1 FROM mytable ...
Read more >
Django - growing up from SQLite to PostgreSQL - Tiny struggles
I narrowed down the issue to a problem with get_or_create . The only thing that changed was the DB, what could there be...
Read more >
get_or_create failure with Django and Postgres (duplicate key ...
Coding example for the question get_or_create failure with Django and Postgres (duplicate key value violates unique constraint)-postgresql.
Read more >
Querying — peewee 3.15.4 documentation
When not using an auto-incrementing primary key, Postgres will return the new row's primary key, but SQLite and MySQL will not. UPDATE -...
Read more >
QuerySet API reference | Django documentation
By default, a QuerySet will not eliminate duplicate rows. In practice, this is rarely a problem, because simple queries such as Blog.objects.all() don't ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found