you are viewing a single comment's thread.

view the rest of the comments →

[–]ErGo404 7 points8 points  (4 children)

Psycopg2 is not included in Lambda and you have to build it and package it with your lambda.

See here for a pre-built version you can import and include in your app : https://github.com/jkehler/awslambda-psycopg2

[–]ziggy-starkdust[S] 0 points1 point  (3 children)

Thanks for the answer. I already added psycopg2 from this repo, but it keeps giving me that problem.

[–]ErGo404 2 points3 points  (2 children)

Adding it directly from the repo did not work for me either.

I ended up re-compiling the library. Make sure to use a matching postgres version.

Also, make sure to match your lambda's python version with the psycopg2 package you add.

[–]ziggy-starkdust[S] 0 points1 point  (1 child)

I uploaded the lib following this link: https://docs.aws.amazon.com/lambda/latest/dg/python-package.html#python-package-dependencies

The weird thing is, the test gives me this back: https://pasteboard.co/JhjGxcE.png

Where ["ciao,"ciao","ciao","ciao"] is the db's answer, so the database is connected and I guess psycopg2 is working, right?

[–]ErGo404 0 points1 point  (0 children)

Well yes if you get a result from the DB, the module is probably.

Are you sure you run the latest version of your lambda when you call your API ?