forked from s_ranjbar/city_retrofit
Merge branch 'db_persistence' into 'master'
Db persistence See merge request Guille/hub!46
This commit is contained in:
commit
c82134b04f
|
@ -1,6 +1,15 @@
|
|||
import logging as logger
|
||||
from pathlib import Path
|
||||
import os
|
||||
|
||||
log_file = (Path(__file__).parent.parent / 'logs/hub.log').resolve()
|
||||
logger.basicConfig(filename=log_file, format="%(asctime)s:%(levelname)s:{%(pathname)s:%(funcName)s:%(lineno)d} "
|
||||
"- %(message)s", level=logger.DEBUG)
|
||||
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}')
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user