1

I am extremely new to postgres (just started up about 30 minutes to an hour ago) and I am already stuck on an error ((node:33564) UnhandledPromiseRejectionWarning: error: syntax error at or near "end").

Currently, I am making a giveaway system for a Discord bot, and I would like the giveaways to still persist even if the bot restarts, which led me to turn to postgres for a database.

This is the code I attempted to use to add a giveaway to the database.

client.query(`INSERT INTO discord.giveaways (content, end, channel, winners, message) VALUES($1, $2, $3, $4, $5)`, [content, end, channel, winners, message]); 

This code returns the following error: (node:33564) UnhandledPromiseRejectionWarning: error: syntax error at or near "end" upon being called.

The value of each variables are the following:

[ 'hello', 1550518888972, '539577989197856776', 1, '547140492039684097' ] 

The columns of the discord.giveaways schema:

1 Answer 1

1

Your column name end is an reserved keyword (see postgres docs).

You can either rename your column name or escape it with ".

Try:

INSERT INTO discord.giveaways (content, "end", channel, winners, message) VALUES ($1, $2, $3, $4, $5); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.