`get_or_create` not working for sqlite/postgresql
See original GitHub issueDescribe 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:
- Created 3 years ago
- Comments:5 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Fixed
related https://github.com/tortoise/tortoise-orm/issues/678