HCE Project Python language Distributed Tasks Manager Application, Distributed Crawler Application and client API bindings.  2.0.0-chaika
Hierarchical Cluster Engine Python language binding
dbi_demo.DemoTaskManager Class Reference
Inheritance diagram for dbi_demo.DemoTaskManager:
Collaboration diagram for dbi_demo.DemoTaskManager:

Public Member Functions

def __init__ (self, config_dic)
 
def process (self, input_tasks)
 

Public Attributes

 dbi
 

Detailed Description

Definition at line 25 of file dbi_demo.py.

Constructor & Destructor Documentation

◆ __init__()

def dbi_demo.DemoTaskManager.__init__ (   self,
  config_dic 
)

Definition at line 28 of file dbi_demo.py.

28  def __init__(self, config_dic):
29  # create dbi instance
30  self.dbi = DBI(config_dic)
31 
32 
def __init__(self)
constructor
Definition: UIDGenerator.py:19

Member Function Documentation

◆ process()

def dbi_demo.DemoTaskManager.process (   self,
  input_tasks 
)

Definition at line 33 of file dbi_demo.py.

33  def process(self, input_tasks):
34  t1 = TasksDataTable()
35  t2 = TasksDataTable()
36  t1.id = 11
37  t2.id = 11
38  t1.data = "fake data 1"
39  t2.data = "fake data 2"
40  self.dbi.insert(t1)
41  print self.dbi.getErrorCode()
42  self.dbi.insert(t2)
43  print self.dbi.getErrorCode()
44  #print self.dbi.fetch(t1, "id=%s"%(t1.id))
45  #print db.session.query(type(t1)).filter(t1.id=t1.id, t1.data=t1.data)
46  print db.session.query(type(t1)).filter_by(id=t1.id, data=t1.data).all()
47  #print self.dbi.sql(t1, "select * from tasks_data_table where id=%s and data='%s'"%(t1.id,t1.data))
48  print self.dbi.getErrorCode()
49  return
50  """
51  # insert one object
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!"
57  return
58  else:
59  # do ptocessing after insertion
60  pass
61  """
62  """
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!"
69  return
70  else:
71  # do ptocessing after insertion
72  pass
73  """
74  return
75  # fetch one object
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:
79  # handle fetch's error
80  print "One fetch error!"
81  return
82  else:
83  # do ptocessing after insertion
84  pass
85  for task in fetched_back_log_tasks:
86  print task
87 
88  """
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!"
95  return
96  else:
97  # do ptocessing after insertion
98  pass
99  for task in fetched_back_log_tasks:
100  print task
101  """
102 
103  """
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!"
110  return
111  else:
112  # do ptocessing after insertion
113  pass
114  for task in fetched_back_log_tasks:
115  print task
116  pass
117  """
118 
119  """
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!"
126  return
127  else:
128  # do ptocessing after insertion
129  pass
130  for task in fetched_back_log_tasks:
131  print task
132  pass
133  """
134 
135  """
136  # update one object
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!"
142  return
143  else:
144  # do ptocessing after insertion
145  pass
146  for task in updated_back_log_tasks:
147  #print vars(task)
148  pass
149  """
150 
151  """
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!"
158  return
159  else:
160  # do ptocessing after insertion
161  pass
162  for task in updated_back_log_tasks:
163  #print vars(task)
164  pass
165  """
166 
167  """
168  # delete one object
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!"
174  return
175  else:
176  # do ptocessing after insertion
177  pass
178  for task in deleted_back_log_tasks:
179  print vars(task)
180  """
181 
182  """
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!"
189  return
190  else:
191  # do ptocessing after insertion
192  pass
193  for task in deleted_back_log_tasks:
194  print vars(task)
195  """
196 
197 
198  # delete all for one object
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:
202  # handle update's error
203  print "delete all for one object error!"
204  return
205  else:
206  # do ptocessing after insertion
207  pass
208  for task in deleted_back_log_tasks:
209  print vars(task)
210 
211 
212  """
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!"
219  return
220  else:
221  # do ptocessing after insertion
222  pass
223  for task in deleted_back_log_tasks:
224  print vars(task)
225  """
226 
Here is the caller graph for this function:

Member Data Documentation

◆ dbi

dbi_demo.DemoTaskManager.dbi

Definition at line 30 of file dbi_demo.py.


The documentation for this class was generated from the following file: