Skip to content

Commit

Permalink
Refactor import and initialization of PsycopgResource class
Browse files Browse the repository at this point in the history
The flask_restful import for Resource has been streamlined to flask_restx, and the initialization process in the PgsqlResource class has been extended with additional *args and **kwargs. This adjustment refines how our resources are initialized, and makes handling database connections in the kwargs argument more straightforward.
  • Loading branch information
maxachis committed May 25, 2024
1 parent fc0b66c commit eb55961
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions resources/PsycopgResource.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import functools
from typing import Callable, Any, Union, Tuple, Dict

from flask_restful import Resource
from flask_restx import abort
from flask_restx import abort, Resource


def handle_exceptions(
Expand Down Expand Up @@ -43,11 +42,12 @@ def wrapper(


class PsycopgResource(Resource):
def __init__(self, **kwargs):
def __init__(self, *args, **kwargs):
"""
Initializes the resource with a database connection.
- kwargs (dict): Keyword arguments containing 'psycopg2_connection' for database connection.
"""
super().__init__(*args, **kwargs)
self.psycopg2_connection = kwargs["psycopg2_connection"]

def get(self):
Expand Down

0 comments on commit eb55961

Please sign in to comment.