import sys
import pymysql
class TransferMoney(object):
def __init__(self,conn):
self.conn=conn
def check_acct_available(self,acctid):
cursor = self.conn.cursor()
try:
sql = "select * from account where accid = '%s' " %acctid
cursor.execute(sql)
rs = cursor.fetchall()
if len(rs) != 1:
raise Exception("账号'%s'不存在" % acctid)
finally:
cursor.close()
def has_enough_money(self,acctid,money):
cursor = self.conn.cursor()
try:
sql = "select * from account where accid = '%s' and money > '%d'" % (acctid,money)
cursor.execute(sql)
rs = cursor.fetchall()
if len(rs) != 1:
raise Exception(
pymysql写简易的银行转账系统
最新推荐文章于 2023-01-30 21:31:31 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)