[mod] engines: migrate to setup() from init() for simple tasks

This commit is contained in:
Om Alve
2026-08-23 18:26:13 +05:30
committed by Bnyro
parent fd29de6c55
commit b4f616fed7
44 changed files with 87 additions and 66 deletions

View File

@@ -21,6 +21,8 @@ Implementations
"""
import typing as t
try:
import psycopg2 # type: ignore
except ImportError:
@@ -55,15 +57,17 @@ paging = True
_connection = None
def init(engine_settings):
global _connection # pylint: disable=global-statement
def setup(engine_settings: dict[str, t.Any]) -> bool | None:
if 'query_str' not in engine_settings:
raise ValueError('query_str cannot be empty')
if not engine_settings['query_str'].lower().startswith('select '):
raise ValueError('only SELECT query is supported')
def init(_):
global _connection # pylint: disable=global-statement
_connection = psycopg2.connect(
database=database,
user=username,