| tierno | ae50192 | 2018-02-06 23:17:16 +0100 | [diff] [blame] | 1 | from http import HTTPStatus |
| 2 | |
| 3 | __author__ = "Alfonso Tierno <alfonso.tiernosepulveda@telefonica.com>" |
| tierno | 6ce7cc8 | 2018-01-29 18:44:04 +0100 | [diff] [blame] | 4 | |
| 5 | |
| 6 | class DbException(Exception): |
| 7 | |
| tierno | ae50192 | 2018-02-06 23:17:16 +0100 | [diff] [blame] | 8 | def __init__(self, message, http_code=HTTPStatus.NOT_FOUND): |
| tierno | 0aef0db | 2018-02-01 19:13:07 +0100 | [diff] [blame] | 9 | # TODO change to http.HTTPStatus instead of int that allows .value and .name |
| tierno | 6ce7cc8 | 2018-01-29 18:44:04 +0100 | [diff] [blame] | 10 | self.http_code = http_code |
| tierno | ae50192 | 2018-02-06 23:17:16 +0100 | [diff] [blame] | 11 | Exception.__init__(self, "database exception " + message) |
| tierno | 6ce7cc8 | 2018-01-29 18:44:04 +0100 | [diff] [blame] | 12 | |
| tierno | 0aef0db | 2018-02-01 19:13:07 +0100 | [diff] [blame] | 13 | |
| tierno | ae50192 | 2018-02-06 23:17:16 +0100 | [diff] [blame] | 14 | class DbBase(object): |
| tierno | 6ce7cc8 | 2018-01-29 18:44:04 +0100 | [diff] [blame] | 15 | |
| 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 |