Skip to content

Commit c5fab96

Browse files
committed
Update function to work with new conn input
1 parent 25192f3 commit c5fab96

File tree

1 file changed

+18
-20
lines changed
  • stac_fastapi/pgstac/stac_fastapi/pgstac

1 file changed

+18
-20
lines changed

stac_fastapi/pgstac/stac_fastapi/pgstac/db.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
import attr
88
import orjson
9-
from asyncpg import exceptions, pool
9+
from asyncpg import exceptions, Connection
1010
from buildpg import V, asyncpg, render
11-
from fastapi import FastAPI
11+
from fastapi import FastAPI, Request
1212

1313
from stac_fastapi.types.errors import (
1414
ConflictError,
@@ -82,25 +82,23 @@ async def dbfunc(conn: Connection, func: str, arg: Union[str, Dict]):
8282
"""
8383
with translate_pgstac_errors():
8484
if isinstance(arg, str):
85-
async with pool.acquire() as conn:
86-
q, p = render(
87-
"""
88-
SELECT * FROM :func(:item::text);
89-
""",
90-
func=V(func),
91-
item=arg,
92-
)
93-
return await conn.fetchval(q, *p)
85+
q, p = render(
86+
"""
87+
SELECT * FROM :func(:item::text);
88+
""",
89+
func=V(func),
90+
item=arg,
91+
)
92+
return await conn.fetchval(q, *p)
9493
else:
95-
async with pool.acquire() as conn:
96-
q, p = render(
97-
"""
98-
SELECT * FROM :func(:item::text::jsonb);
99-
""",
100-
func=V(func),
101-
item=json.dumps(arg),
102-
)
103-
return await conn.fetchval(q, *p)
94+
q, p = render(
95+
"""
96+
SELECT * FROM :func(:item::text::jsonb);
97+
""",
98+
func=V(func),
99+
item=json.dumps(arg),
100+
)
101+
return await conn.fetchval(q, *p)
104102

105103

106104
@contextmanager

0 commit comments

Comments
 (0)