I am using AWS Lambda with Python and pg8000 to insert records into a PostgreSQL RDS database.
When conn.run() is called, I get argument errors or syntax errors.
INSERT_SQL:
INSERT INTO crypto_prices (coin, price_usd, timestamp, day_of_week)
VALUES ($1, $2, $3, $4)
ON CONFLICT (coin, timestamp) DO NOTHING;
'params' looks like:
('bitcoin', 115251, '2025-08-04T18:30:40.926246+00:00', 'Monday')
Error in AWS logs (if I use conn.run(INSERT_SQL, params)):
Failed to insert bitcoin: list index out of range
Error in AWS logs (if I use conn.run(INSERT_SQL, *params)):
Failed to insert bitcoin: Connection.run() takes from 2 to 4 positional arguments but 6 were given
Any help is super appreciated, thank you.
def run(self, sql, stream=None, types=None, **params):](github.com/tlocke/pg8000/blob/…). Minus theselfparameter, there are 2 optional and 2 required. The second error you are getting seems to suggest that somehow you are sending more arguments than you expect. From what you provided, there simply isn't enough information about your situation to determine a solution, but I would try running it locally before publishing your code to a lambda.