Merge branch 'db_persistence' into 'master'

Db persistence

See merge request Guille/hub!46
This commit is contained in:
Guillermo Gutierrez Morote 2023-01-17 06:01:46 +00:00
commit c82134b04f
2 changed files with 17 additions and 5 deletions

View File

@ -1,6 +1,15 @@
import logging as logger
from pathlib import Path
import os
log_file = (Path(__file__).parent.parent / 'logs/hub.log').resolve()
log_dir = (Path(__file__).parent.parent / 'logs').resolve()
log_file = (log_dir / 'hub.log').resolve()
try:
if not os.path.isfile(log_file):
os.mkdir(log_dir)
with open(log_file, 'x'):
pass
logger.basicConfig(filename=log_file, format="%(asctime)s:%(levelname)s:{%(pathname)s:%(funcName)s:%(lineno)d} "
"- %(message)s", level=logger.DEBUG)
except IOError as err:
print(f'I/O exception: {err}')

View File

@ -11,6 +11,7 @@ from persistence.db_config import Base
from sqlalchemy.dialects.postgresql import JSONB
from sqlalchemy.orm import relationship
import datetime
import numpy as np
class City(Base):
@ -41,7 +42,9 @@ class City(Base):
self.name = name
self.srs_name = srs_name
self.country_code = country_code
self.lower_corner = l_corner.tolist()
self.upper_corner = u_corner.tolist()
l_corner = l_corner.tolist() if type(l_corner) == np.ndarray else l_corner
u_corner = u_corner.tolist() if type(u_corner) == np.ndarray else u_corner
self.lower_corner = l_corner
self.upper_corner = u_corner