Skip to content

Instantly share code, notes, and snippets.

View hrabryi's full-sized avatar

Jagor Zhizhenka hrabryi

View GitHub Profile
@travishathaway
travishathaway / pyscopg2_decorator.py
Last active July 9, 2023 16:38
Postgres Connections with Python Decorators
from functools import wraps
import psycopg2
####################
# Define Decorator #
####################
def psycopg2_cursor(conn_info):
"""Wrap function to setup and tear down a Postgres connection while
providing a cursor object to make queries with.