Definition at line 25 of file dbi_demo.py.
◆ __init__()
def dbi_demo.DemoTaskManager.__init__ |
( |
|
self, |
|
|
|
config_dic |
|
) |
| |
Definition at line 28 of file dbi_demo.py.
30 self.dbi = DBI(config_dic)
def __init__(self)
constructor
◆ process()
def dbi_demo.DemoTaskManager.process |
( |
|
self, |
|
|
|
input_tasks |
|
) |
| |
Definition at line 33 of file dbi_demo.py.
38 t1.data =
"fake data 1" 39 t2.data =
"fake data 2" 41 print self.dbi.getErrorCode()
43 print self.dbi.getErrorCode()
46 print db.session.query(
type(t1)).filter_by(id=t1.id, data=t1.data).all()
48 print self.dbi.getErrorCode()
52 input_back_log_one_task = DemoBackLogTask(input_tasks[0]) 53 self.dbi.insert(input_back_log_one_task) 54 if self.dbi.getErrorCode() != CONSTANTS.DBI_SUCCESS_CODE: 55 # handle insertion's error 56 print "One insert error!" 59 # do ptocessing after insertion 63 # insert array of objects 64 input_back_log_tasks = [DemoBackLogTask(input_task) for input_task in input_tasks] 65 self.dbi.insert(input_back_log_tasks) 66 if self.dbi.getErrorCode() != CONSTANTS.DBI_SUCCESS_CODE: 67 # handle insertion's error 68 print "Bunch insert error!" 71 # do ptocessing after insertion 76 fetch_back_log_tasks = DemoBackLogTask(input_tasks[0])
77 fetched_back_log_tasks = self.dbi.fetch(fetch_back_log_tasks,
"id=%s"%fetch_back_log_tasks.id)
78 if self.dbi.getErrorCode() != CONSTANTS.DBI_SUCCESS_CODE:
80 print "One fetch error!" 85 for task
in fetched_back_log_tasks:
89 # fetch bunch of objects 90 fetch_back_log_tasks = [DemoBackLogTask(input_task) for input_task in input_tasks] 91 fetched_back_log_tasks = self.dbi.fetch(fetch_back_log_tasks) 92 if self.dbi.getErrorCode() != CONSTANTS.DBI_SUCCESS_CODE: 93 # handle fetch's error 94 print "Bunch of fetch error!" 97 # do ptocessing after insertion 99 for task in fetched_back_log_tasks: 104 # fetch all for one object 105 fetch_back_log_tasks = DemoBackLogTask(input_tasks[0]) 106 fetched_back_log_tasks = self.dbi.fetchAll(fetch_back_log_tasks) 107 if self.dbi.getErrorCode() != CONSTANTS.DBI_SUCCESS_CODE: 108 # handle fetch's error 109 print "fetch all for one object error!" 112 # do ptocessing after insertion 114 for task in fetched_back_log_tasks: 120 # fetch all for bunch of objects 121 fetch_back_log_tasks = [DemoBackLogTask(input_task) for input_task in input_tasks] 122 fetched_back_log_tasks = self.dbi.fetchAll(fetch_back_log_tasks) 123 if self.dbi.getErrorCode() != CONSTANTS.DBI_SUCCESS_CODE: 124 # handle fetch's error 125 print "fetch all for bunch of objects error!" 128 # do ptocessing after insertion 130 for task in fetched_back_log_tasks: 137 update_back_log_tasks = DemoBackLogTask(Task(id="11111", Tries=22)) 138 updated_back_log_tasks = self.dbi.update(update_back_log_tasks, "id=%s"%update_back_log_tasks.id) 139 if self.dbi.getErrorCode() != CONSTANTS.DBI_SUCCESS_CODE: 140 # handle update's error 141 print "update one object error!" 144 # do ptocessing after insertion 146 for task in updated_back_log_tasks: 152 # update bunch of objects 153 update_back_log_tasks = [DemoBackLogTask(input_task) for input_task in input_tasks] 154 updated_back_log_tasks = self.dbi.update(update_back_log_tasks) 155 if self.dbi.getErrorCode() != CONSTANTS.DBI_SUCCESS_CODE: 156 # handle update's error 157 print "update bunch of objects error!" 160 # do ptocessing after insertion 162 for task in updated_back_log_tasks: 169 delete_back_log_tasks = DemoBackLogTask(Task(id="11111")) 170 deleted_back_log_tasks = self.dbi.delete(delete_back_log_tasks, "id=%s"%delete_back_log_tasks.id) 171 if self.dbi.getErrorCode() != CONSTANTS.DBI_SUCCESS_CODE: 172 # handle update's error 173 print "delete one object error!" 176 # do ptocessing after insertion 178 for task in deleted_back_log_tasks: 183 # delete bunch of objects 184 delete_back_log_tasks = [DemoBackLogTask(input_task) for input_task in input_tasks] 185 deleted_back_log_tasks = self.dbi.delete(delete_back_log_tasks) 186 if self.dbi.getErrorCode() != CONSTANTS.DBI_SUCCESS_CODE: 187 # handle update's error 188 print "delete bunch of objects error!" 191 # do ptocessing after insertion 193 for task in deleted_back_log_tasks: 199 delete_back_log_tasks = DemoBackLogTask(input_tasks[0])
200 deleted_back_log_tasks = self.dbi.deleteAll(delete_back_log_tasks)
201 if self.dbi.getErrorCode() != CONSTANTS.DBI_SUCCESS_CODE:
203 print "delete all for one object error!" 208 for task
in deleted_back_log_tasks:
213 # delete all for bunch of objects 214 delete_back_log_tasks = [DemoBackLogTask(input_task) for input_task in input_tasks] 215 deleted_back_log_tasks = self.dbi.deleteAll(delete_back_log_tasks) 216 if self.dbi.getErrorCode() != CONSTANTS.DBI_SUCCESS_CODE: 217 # handle update's error 218 print "delete all for bunch of objects error!" 221 # do ptocessing after insertion 223 for task in deleted_back_log_tasks:
◆ dbi
dbi_demo.DemoTaskManager.dbi |
The documentation for this class was generated from the following file: