This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
# from contextlib import contextmanager
|
||||
from typing import Any, Callable, Dict, TypeVar
|
||||
|
||||
# from psycopg2.errors import UniqueViolation
|
||||
from sqlalchemy import Column, Integer, create_engine
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
@@ -18,7 +19,7 @@ REGISTRY: Dict[str, type] = {}
|
||||
# @contextmanager
|
||||
def local_session(src=""):
|
||||
return Session(bind=engine, expire_on_commit=False)
|
||||
|
||||
|
||||
# try:
|
||||
# yield session
|
||||
# session.commit()
|
||||
@@ -60,8 +61,8 @@ class Base(declarative_base()):
|
||||
except Exception as e:
|
||||
print(f"[services.db] Error dict: {e}")
|
||||
return {}
|
||||
|
||||
|
||||
def update(self, values: Dict[str, Any]) -> None:
|
||||
for key, value in values.items():
|
||||
if hasattr(self, key):
|
||||
setattr(self, key, value)
|
||||
for key, value in values.items():
|
||||
if hasattr(self, key):
|
||||
setattr(self, key, value)
|
||||
|
Reference in New Issue
Block a user