Skip to content

Commit

Permalink
from create_connection to get_connection
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanix-Darker committed Aug 20, 2023
1 parent 86fbeb1 commit 73d98be
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 3 additions & 3 deletions api/app/main/utils/database/search_projects.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# database utils functions

from app.settings import create_connection
from app.settings import get_connection


async def get_search_projects(query: str, count: int = 20, page: int = 1):
offset = (page - 1) * count
conn = await create_connection()
conn = await get_connection()

try:
ret = conn.fetch(
Expand All @@ -32,7 +32,7 @@ async def post_search_projects(
page: int = 1
):
offset = (page - 1) * count
conn = await create_connection()
conn = await get_connection()

try:
if sort_type == 'alphabetic':
Expand Down
11 changes: 6 additions & 5 deletions api/app/main/utils/database/search_users.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# database utils functions

from app.settings import create_connection, get_connection
from app.settings import get_connection


async def get_user(username: str) -> dict:
conn = await create_connection()
conn = await get_connection()

try:
ret = await conn.fetch(
Expand All @@ -19,8 +19,9 @@ async def get_user(username: str) -> dict:
return ret

async def get_users(count: int) -> dict:
conn = await get_connection()
try:
ret = await get_connection().fetch(
ret = conn.fetch(
'SELECT * FROM users LIMIT $1', count
)
finally:
Expand All @@ -34,7 +35,7 @@ async def get_users(count: int) -> dict:

async def get_search_users(query: str, count: int = 20, page: int = 1):
offset = (page - 1) * count
conn = await create_connection()
conn = await get_connection()

try:
ret = await conn.fetch(
Expand All @@ -57,7 +58,7 @@ async def post_search_users(
page: int = 1
):
offset = (page - 1) * count
conn = await create_connection()
conn = await get_connection()

try:
if sort_type == 'alphabetic':
Expand Down
1 change: 1 addition & 0 deletions api/app/main/utils/database/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from app.main.utils import converters


def sanitize_user_data(data):
"""
sanitize_user_data [prepare user data format]
Expand Down

0 comments on commit 73d98be

Please sign in to comment.