blob: b101cb433ca73c61a870e8b8b2b2cb15d590a639 [file] [log] [blame]
tiernoae501922018-02-06 23:17:16 +01001from http import HTTPStatus
2
3__author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>"
tierno6ce7cc82018-01-29 18:44:04 +01004
5
6class DbException(Exception):
7
tiernoae501922018-02-06 23:17:16 +01008 def __init__(self, message, http_code=HTTPStatus.NOT_FOUND):
tierno0aef0db2018-02-01 19:13:07 +01009 # TODO change to http.HTTPStatus instead of int that allows .value and .name
tierno6ce7cc82018-01-29 18:44:04 +010010 self.http_code = http_code
tiernoae501922018-02-06 23:17:16 +010011 Exception.__init__(self, "database exception " + message)
tierno6ce7cc82018-01-29 18:44:04 +010012
tierno0aef0db2018-02-01 19:13:07 +010013
tiernoae501922018-02-06 23:17:16 +010014class DbBase(object):
tierno6ce7cc82018-01-29 18:44:04 +010015
16 def __init__(self):
17 pass
18
19 def db_connect(self, config):
20 pass
21
22 def db_disconnect(self):
23 pass
24
25 def get_list(self, table, filter={}):
26 pass
27
28 def get_one(self, table, filter={}, fail_on_empty=True, fail_on_more=True):
29 pass
30
31 def create(self, table, indata):
32 pass
33
34 def del_list(self, table, filter={}):
35 pass
36
37 def del_one(self, table, filter={}, fail_on_empty=True):
38 pass