asyncpg raising syntax error #940
-
Code: class Poll(Table, tablename="polls"):
id = Serial(primary_key=True)
author_id = BigInt()
channel_id = BigInt()
message_id = BigInt(null=True)
question = Varchar()
options = Array(Varchar())
votes = Array(Array(BigInt()))
# Somewhere else in code
async def foo():
poll = Poll(
author_id=000000000000000000,
channel_id=000000000000000000,
question="Hello?",
options=["Hi?", "Hey?"],
votes=[[] for _ in choices],
)
await poll.insert() Error:
|
Beta Was this translation helpful? Give feedback.
Answered by
sinisaos
Mar 4, 2024
Replies: 1 comment 1 reply
-
@AmazingAkai You are mixing async def foo():
poll = await Poll.insert(
Poll(
author_id=000000000000000000,
channel_id=000000000000000000,
question="Hello?",
options=["Hi?", "Hey?"],
votes=[[] for _ in choices],
)
) or you can use async def foo():
poll = Poll(
author_id=000000000000000000,
channel_id=000000000000000000,
question="Hello?",
options=["Hi?", "Hey?"],
votes=[[] for _ in choices],
)
await poll.save()
) |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
dantownsend
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@AmazingAkai You are mixing
save
andinsert
methods. You must use aninsert
method like this:or you can use
save
method to save object like this: