Initial commit

This commit is contained in:
Anton Kamalov
2024-10-21 22:42:14 +03:00
commit 19a5869d30
14 changed files with 228 additions and 0 deletions

14
App/db/sql_provider.py Normal file
View File

@@ -0,0 +1,14 @@
import os
from string import Template
class SQLProvider:
def __init__(self, file_path):
self.scripts = {}
for file in os.listdir(file_path):
_sql = open(f'{file_path}/{file}').read()
self.scripts[file] = Template(_sql)
def get(self, name, params) -> dict:
if name not in self.scripts:
raise ValueError(f'SQL template {name} not found')
return self.scripts[name].substitute(**params)