Skip to content

Commit

Permalink
feat: pass connection number as params
Browse files Browse the repository at this point in the history
  • Loading branch information
dlbrittain committed Apr 12, 2023
1 parent 9c152ec commit 4ec56a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dynamicannotationdb/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@


class DynamicAnnotationDB:
def __init__(self, sql_url: str) -> None:
def __init__(self, sql_url: str, pool_size=5, max_overflow=5) -> None:

self._cached_session = None
self._cached_tables = {}
self._engine = create_engine(
sql_url, pool_recycle=3600, pool_size=20, max_overflow=50
sql_url, pool_recycle=3600, pool_size=pool_size, max_overflow=max_overflow
)
self.base = Base
self.base.metadata.bind = self._engine
Expand Down
10 changes: 8 additions & 2 deletions dynamicannotationdb/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ class DynamicAnnotationInterface:
"""

def __init__(self, url: str, aligned_volume: str) -> None:
def __init__(
self, url: str, aligned_volume: str, pool_size=5, max_overflow=5
) -> None:
self._annotation = None
self._database = None
self._segmentation = None
self._schema = None
self.pool_size = pool_size
self.max_overflow = max_overflow
self._base_url = url.rpartition("/")[0]
self._aligned_volume = aligned_volume
self._sql_url = self.create_or_select_database(url, aligned_volume)
Expand Down Expand Up @@ -159,7 +163,9 @@ def annotation(self) -> DynamicAnnotationClient:
@property
def database(self) -> DynamicAnnotationDB:
if not self._database:
self._database = DynamicAnnotationDB(self._sql_url)
self._database = DynamicAnnotationDB(
self._sql_url, self.pool_size, self.max_overflow
)
return self._database

@property
Expand Down

0 comments on commit 4ec56a7

Please sign in to comment.