|
|
@ -31,12 +31,23 @@ def checkBank(a):
|
|
|
|
dirOutput = os.listdir()
|
|
|
|
dirOutput = os.listdir()
|
|
|
|
matchs = [match for match in dirOutput if 'db.sqlite' in match]
|
|
|
|
matchs = [match for match in dirOutput if 'db.sqlite' in match]
|
|
|
|
for i in matchs:
|
|
|
|
for i in matchs:
|
|
|
|
|
|
|
|
print(i)
|
|
|
|
checkBank.bnktst = 'fail'
|
|
|
|
checkBank.bnktst = 'fail'
|
|
|
|
if a == i.split(".")[0]:
|
|
|
|
if a == i.split(".")[0]:
|
|
|
|
checkBank.bnktst = 'pass'
|
|
|
|
checkBank.bnktst = 'pass'
|
|
|
|
if checkBank.bnktst != "pass":
|
|
|
|
if checkBank.bnktst != "pass":
|
|
|
|
return_37(a)
|
|
|
|
return_37(a)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def userBalance(a):
|
|
|
|
|
|
|
|
connDb = sqlite3.connect(a)
|
|
|
|
|
|
|
|
cur = connDb.cursor()
|
|
|
|
|
|
|
|
balUser = input('User? ').lower()
|
|
|
|
|
|
|
|
userCheck(balUser,a)
|
|
|
|
|
|
|
|
cur.execute("SELECT id FROM account where username=?", (balUser, ))
|
|
|
|
|
|
|
|
userId = cur.fetchone()[0]
|
|
|
|
|
|
|
|
bal = cur.execute("SELECT balance from balance1 where id=?", (userId, )).fetchall()
|
|
|
|
|
|
|
|
print(bal)
|
|
|
|
|
|
|
|
|
|
|
|
def transfer(a):
|
|
|
|
def transfer(a):
|
|
|
|
clear()
|
|
|
|
clear()
|
|
|
|
print()
|
|
|
|
print()
|
|
|
@ -117,7 +128,7 @@ def manBankin(a):
|
|
|
|
elif userIn == "3":
|
|
|
|
elif userIn == "3":
|
|
|
|
transfer(a)
|
|
|
|
transfer(a)
|
|
|
|
elif userIn == "4":
|
|
|
|
elif userIn == "4":
|
|
|
|
print("User balance")
|
|
|
|
userBalance(a)
|
|
|
|
elif userIn == "9":
|
|
|
|
elif userIn == "9":
|
|
|
|
manageBankmenu(a)
|
|
|
|
manageBankmenu(a)
|
|
|
|
elif userIn == "8":
|
|
|
|
elif userIn == "8":
|
|
|
@ -218,10 +229,28 @@ def selectBank():
|
|
|
|
manageBankmenu(manBank)
|
|
|
|
manageBankmenu(manBank)
|
|
|
|
|
|
|
|
|
|
|
|
def addBank():
|
|
|
|
def addBank():
|
|
|
|
clear()
|
|
|
|
|
|
|
|
print('Add a bank: ')
|
|
|
|
print('Add a bank: ')
|
|
|
|
print()
|
|
|
|
print()
|
|
|
|
bankName = input("What would you like to call this bank? ").lower()
|
|
|
|
bankName = input("What would you like to call this bank? ").lower()
|
|
|
|
|
|
|
|
if not bankName:
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
print('Not a valid name. ')
|
|
|
|
|
|
|
|
mainFunc()
|
|
|
|
|
|
|
|
elif bankName.isspace() == True:
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
mainFunc()
|
|
|
|
|
|
|
|
dirOutput = os.listdir()
|
|
|
|
|
|
|
|
matchs = [match for match in dirOutput if 'db.sqlite' in match]
|
|
|
|
|
|
|
|
for i in matchs:
|
|
|
|
|
|
|
|
checkBank.nametst = 'pass'
|
|
|
|
|
|
|
|
if bankName == i.split(".")[0]:
|
|
|
|
|
|
|
|
addBank.nametst = 'fail'
|
|
|
|
|
|
|
|
if addBank.nametst != "pass":
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
print('~Name already exists! ')
|
|
|
|
|
|
|
|
print()
|
|
|
|
|
|
|
|
mainFunc()
|
|
|
|
|
|
|
|
|
|
|
|
bankName = bankName+".db.sqlite"
|
|
|
|
bankName = bankName+".db.sqlite"
|
|
|
|
connDb = sqlite3.connect(bankName)
|
|
|
|
connDb = sqlite3.connect(bankName)
|
|
|
|
connDb.execute('''CREATE TABLE account
|
|
|
|
connDb.execute('''CREATE TABLE account
|
|
|
@ -242,7 +271,7 @@ def addBank():
|
|
|
|
AMOUNT INTEGER NOT NULL,
|
|
|
|
AMOUNT INTEGER NOT NULL,
|
|
|
|
TIMESTAMP DATETIME DEFAULT CURRENT_TIMESTAMP);''')
|
|
|
|
TIMESTAMP DATETIME DEFAULT CURRENT_TIMESTAMP);''')
|
|
|
|
connDb.close()
|
|
|
|
connDb.close()
|
|
|
|
clear()
|
|
|
|
# clear()
|
|
|
|
print()
|
|
|
|
print()
|
|
|
|
print(f'*** Added bank {bankName}')
|
|
|
|
print(f'*** Added bank {bankName}')
|
|
|
|
print()
|
|
|
|
print()
|
|
|
@ -284,7 +313,7 @@ def mainFunc():
|
|
|
|
2. Add new bank.
|
|
|
|
2. Add new bank.
|
|
|
|
3. List banks.
|
|
|
|
3. List banks.
|
|
|
|
4. Delete a bank.
|
|
|
|
4. Delete a bank.
|
|
|
|
Q to quit.
|
|
|
|
9 to quit.
|
|
|
|
""")
|
|
|
|
""")
|
|
|
|
mainOption = int(input("Choose an option: "))
|
|
|
|
mainOption = int(input("Choose an option: "))
|
|
|
|
if mainOption == 1:
|
|
|
|
if mainOption == 1:
|
|
|
@ -295,7 +324,7 @@ def mainFunc():
|
|
|
|
listBank()
|
|
|
|
listBank()
|
|
|
|
elif mainOption == 4:
|
|
|
|
elif mainOption == 4:
|
|
|
|
delBank()
|
|
|
|
delBank()
|
|
|
|
elif mainOption == 'Q':
|
|
|
|
elif mainOption == 9:
|
|
|
|
exit()
|
|
|
|
exit()
|
|
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|