Exemple #1
0
 def add_money(self, acctid, money):
     cursor = self.conn.cursor()
     try:
         sql = "update account set money=money+%s where acctid='%s'"% (money,acctid)
         cursor.execute(sql)
         rs = cursor.fetchall()
         if  cursor.rowcount != 1:
             raise Exception("%s转账失败!" % acctid)
     finally:
         cursor.close()
Exemple #2
0
 def reduce_money(self,acctid,money):
     cursor = self.conn.cursor()
     try:
         sql = "update account set money= money-%s where acctid='%s'"% (money,acctid)
         cursor.execute(sql)
         print (sql)
         if  cursor.rowcount != 1:
             raise Exception("账户s%扣款失败" % acctid)
     finally:
         cursor.close()
Exemple #3
0
 def add_money(self, acctid, money):
     cursor = self.conn.cursor()
     try:
         sql = "update account set money=money+%s where acctid='%s'" % (
             money, acctid)
         cursor.execute(sql)
         rs = cursor.fetchall()
         if cursor.rowcount != 1:
             raise Exception("%s转账失败!" % acctid)
     finally:
         cursor.close()
Exemple #4
0
 def reduce_money(self, acctid, money):
     cursor = self.conn.cursor()
     try:
         sql = "update account set money= money-%s where acctid='%s'" % (
             money, acctid)
         cursor.execute(sql)
         print(sql)
         if cursor.rowcount != 1:
             raise Exception("账户s%扣款失败" % acctid)
     finally:
         cursor.close()
Exemple #5
0
 def check_acct_available(self, acctid):
     cursor = self.conn.cursor()
     try:
         sql = "select * from account where acctid='%s'" % acctid
         #             print sql
         cursor.execute(sql)
         print("check_acct_available: %s " % sql)
         rs = cursor.fetchall()
         if len(rs) != 1:
             raise Exception("账号s%校验失败" % acctid)
     finally:
         cursor.close()
Exemple #6
0
    def check_acct_available(self,acctid):
        cursor = self.conn.cursor()
        try:
            sql = "select * from account where acctid='%s'" %acctid
#             print sql
            cursor.execute(sql)
            print ("check_acct_available: %s " % sql)
            rs = cursor.fetchall()
            if  len(rs) !=1:
                raise Exception("账号s%校验失败" % acctid)
        finally:
            cursor.close()
Exemple #7
0
    def has_enough_money(self,acctid,money):
        cursor = self.conn.cursor()
        try:

            sql = "select * from account where  acctid=%s and money>%s" % (acctid, money)
            print (sql)
            cursor.execute(sql)
            print ("has_enough_money: " + sql)
            rs = cursor.fetchall()
            print len(rs)
            if  len(rs) !=1:
                raise Exception("账户s%金额不够��" % acctid)
        finally:
            cursor.close()
Exemple #8
0
    def has_enough_money(self, acctid, money):
        cursor = self.conn.cursor()
        try:

            sql = "select * from account where  acctid=%s and money>%s" % (
                acctid, money)
            print(sql)
            cursor.execute(sql)
            print("has_enough_money: " + sql)
            rs = cursor.fetchall()
            print len(rs)
            if len(rs) != 1:
                raise Exception("账户s%金额不够��" % acctid)
        finally:
            cursor.close()