psqlpy-python / psqlpy

Asynchronous Python PostgreSQL driver written in Rust
https://psqlpy-python.github.io/
MIT License
213 stars 3 forks source link

Too difficult to implement in AWS Lambda as a Layer #88

Open codepinto opened 1 week ago

codepinto commented 1 week ago

I recently implemented psycopg3 in my AWS Lambda function as a Layer to successfully query my AWS RDS database. What made this process manageable was the abundance of additional documentation for psycopg3—both from official sources and community-driven content (e.g., forum posts, videos). This was invaluable for understanding how to make it work in this specific environment.

However, I believe psqlpy has the potential to surpass psycopg3 in terms of usability and market adoption, particularly for AWS Lambda use cases. With a few targeted improvements, you could make psqlpy much easier for end users to integrate into AWS Lambda environments.

Suggestions: Improve AWS Lambda compatibility: Simplifying the process for using psqlpy as an AWS Lambda Layer would be a significant advantage.

Reasons:

  1. Even the current solutions (e.g., psycopg3) lack sufficient documentation for Lambda integration, which leaves users spending unnecessary time troubleshooting. By addressing this, psqlpy could easily capture a larger user base.

  2. This is an easy-to-implement improvement ("low-hanging fruit") that would open the door to greater adoption, especially as AWS Lambda is such a widely-used service.

Next Steps:

  1. Create streamlined instructions for AWS Lambda integration: Provide clear, step-by-step documentation or a guide on how to download and structure psqlpy for AWS Lambda Layers.

  2. Provide a command or script for packaging psqlpy: An example of a command I used for psycopg3 that sets up the correct directory structure for Lambda is below. This makes it easy to generate a zip file and upload it to AWS as a Layer:

mkdir python\lib\python3.12\site-packages
pip install --platform manylinux2014_x86_64 --target=python/lib/python3.12/site-packages --implementation cp --python-version 3.12 --only-binary=:all: --upgrade "psycopg[binary]"
zip -r9 lambda_function.zip python
  1. Provide an AWS Lambda example: A sample Lambda function using psqlpy to query a database would be incredibly useful. AWS requires the main file to be named lambda_function.py and the function inside to be named lambda_handler. Having a working example would save developers significant time during setup.

By implementing these suggestions, I believe psqlpy could achieve much greater adoption, particularly within the AWS Lambda ecosystem.

I hope these suggestions help, and I’m happy to discuss further if needed. I look forward to supporting this project as it continues to evolve.

chandr-andr commented 1 week ago

Thank you very much! I'll try to figure out how to run PSQLPy on AWS Lambda and make normal guide.