Skip to content

Instantly share code, notes, and snippets.

View ayharano's full-sized avatar

Alexandre Yukio Harano ayharano

View GitHub Profile
@ayharano
ayharano / sqlalchemy-rds-iam-pgsql.py
Created December 9, 2025 22:15 — forked from gdamjan/sqlalchemy-rds-iam-pgsql.py
SQLAlchemy with RDS IAM Authentication
'''
Example of IAM Authentication to Postgres RDS from Python and SQLAlchemy. Uses SQLAlchemy events to
run a callback just before making a db connection and adding it to the internal pool. The callback
sets the connection parameters including the password/token.
https://docs.sqlalchemy.org/en/14/core/events.html#sqlalchemy.events.DialectEvents.do_connect
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.html
https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.IAMDBAuth.Connecting.Python.html
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/rds.html#RDS.Client.generate_db_auth_token
@ayharano
ayharano / README.md
Created November 26, 2025 18:02 — forked from liviaerxin/README.md
FastAPI and Uvicorn Logging #python #fastapi #uvicorn #logging

FastAPI and Uvicorn Logging

When running FastAPI app, all the logs in console are from Uvicorn and they do not have timestamp and other useful information. As Uvicorn applies python logging module, we can override Uvicorn logging formatter by applying a new logging configuration.

Meanwhile, it's able to unify the your endpoints logging with the Uvicorn logging by configuring all of them in the config file log_conf.yaml.

Before overriding:

uvicorn main:app --reload
@ayharano
ayharano / deny_snippet.json
Created March 7, 2024 14:10 — forked from astuyve/deny_snippet.json
Deny cloudwatch permissions from Lambda to save money
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
@ayharano
ayharano / README.md
Created June 20, 2019 23:36 — forked from joyrexus/README.md
collapsible markdown

collapsible markdown?

CLICK ME

yes, even hidden code blocks!

print("hello world!")