Skip to content

Commit

Permalink
ready for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
arrafi-musabbir committed May 5, 2021
1 parent 9ba13bc commit 0269b8f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions database.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,14 @@ def clearEntries(self, n):
try:
for i in range(n):
self.mycursor.execute(
"DELETE FROM {} ORDER BY CreatedOn DESC LIMIT 1".format(self.table_name))
"SELECT ID FROM {} ORDER BY ID DESC LIMIT 1".format(self.table_name))
qr_file = self.mycursor.fetchone()[0][1:]
try:
os.remove(os.path.join(os.getcwd(),'QRs//'+qr_file+'.png'))
except FileNotFoundError:
print("QR for ID {} does not exists".format(qr_file))
self.mycursor.execute(
"DELETE FROM {} ORDER BY ID DESC LIMIT 1".format(self.table_name))
self.myDB.commit()
print(n, "number of entries deletation succcessfull")
except AttributeError:
Expand All @@ -139,7 +146,7 @@ def getTotalID(self):

# get last registered ID of current date
def getLastID(self):
self.mycursor.execute("SELECT ID FROM {} ORDER BY CreatedOn DESC LIMIT 1".format(self.table_name))
self.mycursor.execute("SELECT ID FROM {} ORDER BY ID DESC LIMIT 1".format(self.table_name))
lastidYMD = self.mycursor.fetchall()[0][0]
if lastidYMD[-12:-4] != datetime.today().strftime("%Y%m%d"):
return 0
Expand Down Expand Up @@ -190,8 +197,9 @@ def importCSV(self):
# a.connectDB()
# # a.describeTable()
# a.exportCSV()
a.importCSV()
# a.importCSV()
# # a.clearTable()
# # print(a.getTotalID())
# print(a.getLastID())
print(a.getLastID())
# a.clearEntries(1)
# a.disconnect()

0 comments on commit 0269b8f

Please sign in to comment.