33 lines
844 B
Python
33 lines
844 B
Python
import json
|
|
import logging
|
|
import pydapper
|
|
|
|
from ..schemas import model
|
|
from .. import local_db
|
|
|
|
def GetBerths(token):
|
|
"""
|
|
No parameters, gets all entries
|
|
"""
|
|
|
|
try:
|
|
pooledConnection = local_db.getPoolConnection()
|
|
commands = pydapper.using(pooledConnection)
|
|
data = commands.query("SELECT id, name, `lock`, owner_id, authority_id, created, modified, deleted FROM berth WHERE deleted = 0 ORDER BY name", model=model.Berth)
|
|
return json.dumps(data, default=model.obj_dict), 200, {'Content-Type': 'application/json; charset=utf-8'}
|
|
|
|
except Exception as ex:
|
|
logging.error(ex)
|
|
print(ex)
|
|
result = {}
|
|
result["message"] = "call failed"
|
|
return json.dumps(result), 500
|
|
|
|
finally:
|
|
if pooledConnection is not None:
|
|
pooledConnection.close()
|
|
|
|
|
|
|
|
|