Skip to content

feat(functions): PostgreSQL Python example #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 24, 2023
Merged

Conversation

redanrd
Copy link
Contributor

@redanrd redanrd commented Mar 14, 2023

Summary

This example shows a serverless function in Python to connect to PosgreSQL database.

Checklist

  • I have reviewed this myself.
  • I have attached a README to my example. You can use this template as reference.
  • I have updated the project README to link my example.

@redanrd redanrd changed the title PostgreSQL python example WIP: PostgreSQL python example Mar 14, 2023
@redanrd redanrd added functions Serverless Function Example do not merge labels Mar 14, 2023
@redanrd redanrd changed the title WIP: PostgreSQL python example feat(functions): PostgreSQL python example Mar 14, 2023
@redanrd redanrd requested a review from cyclimse March 14, 2023 15:22
@redanrd redanrd changed the title feat(functions): PostgreSQL python example WIP feat(functions): PostgreSQL python example Mar 14, 2023
@redanrd redanrd removed the request for review from cyclimse March 14, 2023 16:59
@redanrd redanrd changed the title WIP feat(functions): PostgreSQL python example WIP feat(functions): PostgreSQL Python example Mar 14, 2023
@redanrd redanrd changed the title WIP feat(functions): PostgreSQL Python example feat(functions): PostgreSQL Python example Mar 24, 2023
Comment on lines +6 to +11
PG_HOST=os.environ.get('PG_HOST')
PG_USER=os.environ.get('PG_USER')
PG_DATABASE=os.environ.get('PG_DATABASE')
PG_PASSWORD=os.environ.get('PG_PASSWORD')
PG_PORT=os.environ.get('PG_PORT')
PG_SSL_ROOT_CERT=os.environ.get('PG_SSL_ROOT_CERT')
Copy link
Contributor

@cyclimse cyclimse Mar 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
PG_HOST=os.environ.get('PG_HOST')
PG_USER=os.environ.get('PG_USER')
PG_DATABASE=os.environ.get('PG_DATABASE')
PG_PASSWORD=os.environ.get('PG_PASSWORD')
PG_PORT=os.environ.get('PG_PORT')
PG_SSL_ROOT_CERT=os.environ.get('PG_SSL_ROOT_CERT')
PG_HOST=os.environ["PG_HOST"]
PG_USER=os.environ["PG_USER"]
PG_DATABASE=os.environ["PG_DATABASE"]
PG_PASSWORD=os.environ["PG_PASSWORD"]
PG_PORT=os.environ["'PG_PORT"]
PG_SSL_ROOT_CERT=os.environ["PG_SSL_ROOT_CERT"]

I prefer os.getenv instead of os.environ.get. But because here those env vars are required, it's even better to catch the error early.

@redanrd redanrd merged commit 706c5c6 into main Mar 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
functions Serverless Function Example
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants