Skip to content

Commit

Permalink
once again, back to on demand DB connections
Browse files Browse the repository at this point in the history
  • Loading branch information
PhillipsOwen committed Mar 17, 2023
1 parent 70643fe commit f3af3f6
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from src.common.pg_impl import PGImplementation

# set the app version
APP_VERSION = 'v0.3.2'
APP_VERSION = 'v0.3.3'

# declare the FastAPI details
APP = FastAPI(title='APSVIZ UI Data', version=APP_VERSION)
Expand All @@ -42,9 +42,6 @@
# note the extra comma makes this single item a singleton tuple
db_name: tuple = ('apsviz',)

# create a DB connection object
db_info: PGImplementation = PGImplementation(db_name, _logger=logger)


@APP.get('/get_ui_data', status_code=200, response_model=None)
async def get_terria_map_catalog_data(grid_type: Union[str, None] = Query(default=None), event_type: Union[str, None] = Query(default=None),
Expand Down Expand Up @@ -86,6 +83,9 @@ async def get_terria_map_catalog_data(grid_type: Union[str, None] = Query(defaul
# add this parm to the list
kwargs.update({param: 'null' if not locals()[param] else f"'{locals()[param]}'"})

# create a DB connection object
db_info: PGImplementation = PGImplementation(db_name, _logger=logger)

# try to make the call for records
ret_val: dict = db_info.get_terria_map_catalog_data(**kwargs)
except Exception:
Expand Down Expand Up @@ -154,6 +154,9 @@ async def get_terria_map_catalog_data_file(file_name: Union[str, None] = Query(d
temp_file_path: str = os.path.join(temp_file_path, file_name)

try:
# create a DB connection object
db_info: PGImplementation = PGImplementation(db_name, _logger=logger)

# try to make the call for records
ret_val: dict = db_info.get_terria_map_catalog_data(**kwargs)

Expand Down

0 comments on commit f3af3f6

Please sign in to comment.