awslambda-psycopg2 | This is a custom compiled psycopg2 C library for Python | SQL Database library
kandi X-RAY | awslambda-psycopg2 Summary
kandi X-RAY | awslambda-psycopg2 Summary
This is a custom compiled psycopg2 C library for Python. Due to AWS Lambda missing the required PostgreSQL libraries in the AMI image, we needed to compile psycopg2 with the PostgreSQL libpq.so library statically linked libpq library instead of the default dynamic link.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Execute a series of values
- Splits the given sql string
- Paginate a sequence of pages
- Register an hstore
- Get the oids of the hstore
- Resolve a connection or cursor
- Initialize a database from the database
- Create a dsn from a dsn
- Escape a string
- Create a RangeCaster instance
- Initialize a database from a database
- Register IP address adapters
- Execute a batch query
- Join rows together
- Parse a string into a data structure
- Register default JSONBARRAY
- Register a JSON file
- Add a connection to the pool
- Get a connection object
- Fetch a single record
- Parse a unicode string
- Get a connection from the cache
- Close all connections
- Returns a list of dictionaries
- Log msg to file
- Fetch all namedtuples
awslambda-psycopg2 Key Features
awslambda-psycopg2 Examples and Code Snippets
pip install requests -t .
.
├── lambda_function.py
├── psycopg2
├──
conn_string = "dbname='your_db_name' port='5439' user='redshift_user' password='^%+^+&7!+' host='xxxxxxx.yyyyyyy.eu-west-1.redshift.amazonaws.com'"
conn = psycopg.connect(conn_string)
cursor = conn.cursor()
cursor.execute("COPY data
$ cd ~/lambda
$ zip lambda_function.zip lambda_function.py
$ zip -r lambda_function.zip multiprocessing*
Community Discussions
Trending Discussions on awslambda-psycopg2
QUESTION
I am trying to add the packages for psycopg2 into my zipped folder for my python lambda function. I am using Python version 3.8. Here is the psycopg2 documentation psycopg2.
From these docs it seems like I have to pull the folder for psycopg2-3.8 into the zipped file for my lambda function. However, I cannot seem to get this to successfully run.
I am using a virtual environment and creating the zip file according to these AWS docs for virtual environment
To get the psycopg folder zipped I am running zip -g my-deployment-package.zip psycopg2
The error I am receiving is
...ANSWER
Answered 2021-Feb-21 at 02:43psycopg2-binary is a binary pip package of psycopg2
which comes with all dependencies and does not require compiling. To use it in your lambda function, you can create a lambda layer using docker as described in the AWS blog.
Thus you can add psycopg2-binary
to your function as follows:
Create empty folder, e.g.
mylayer
.Go to the folder and create
requirements.txt
file with the content of
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install awslambda-psycopg2
You can use awslambda-psycopg2 like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page