|
56
|
1 |
# -*- coding: utf-8 -*- |
|
|
2 |
|
|
|
3 |
from database import Database |
|
|
4 |
|
|
|
5 |
class Acounting(Database): |
|
|
6 |
def __init__(self,id, connection): |
|
|
7 |
Database.__init__(self,connection) |
|
|
8 |
self.id=id |
|
|
9 |
|
|
|
10 |
def setId(self,id): |
|
|
11 |
self.id=id |
|
|
12 |
|
|
|
13 |
def getStatus(self): |
|
|
14 |
self.connect() |
|
|
15 |
self.cursor.execute ("SELECT status,tel FROM %s WHERE id='%s'" % (self.connection['table'], self.id)) |
|
|
16 |
ret= self.cursor.fetchall() |
|
|
17 |
self.disconnect() |
|
|
18 |
return ret |
|
|
19 |
|
|
|
20 |
def addGood(self, good,disconnect=True): |
|
|
21 |
if type(good) == list: |
|
|
22 |
for i in good: |
|
|
23 |
self.addGood(i) |
|
|
24 |
if disconnect: |
|
|
25 |
self.disconnect() |
|
|
26 |
else: |
|
|
27 |
self.connect() |
|
|
28 |
self.cursor.execute("INSERT INTO %s (id,tel,status) VALUES('%s','%s','sended')" % (self.connection['table'], self.id, good)) |
|
|
29 |
if disconnect: |
|
|
30 |
self.disconnect() |
|
|
31 |
|
|
|
32 |
|
|
|
33 |
def addFailed(self, failed,disconnect=True): |
|
|
34 |
if type(failed) == list: |
|
|
35 |
for i in failed: |
|
|
36 |
self.addFailed(i,False) |
|
|
37 |
if disconnect: |
|
|
38 |
self.disconnect() |
|
|
39 |
else: |
|
|
40 |
self.connect() |
|
|
41 |
self.cursor.execute ("INSERT INTO %s (id,tel,status) VALUES('%s','%s','failed')"%(self.connection['table'], self.id, failed)) |
|
|
42 |
if disconnect: |
|
|
43 |
self.disconnect() |