Skip to content

Commit

Permalink
fixed bug in importCSV to database
Browse files Browse the repository at this point in the history
  • Loading branch information
arrafi-musabbir committed May 5, 2021
1 parent 8e3242c commit 9ba13bc
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions database.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,18 +171,12 @@ def exportCSV(self):
def importCSV(self):
self.clearTable()
try:
n=0
with open(os.path.join(self.csv_path,'exportedFromSheet_{}.csv'.format(datetime.today().strftime('%d %b %Y'))), 'r') as file:
csv_data = csv.reader(file, delimiter = ',')
for i in csv_data:
if len(i) > 0:
if n == 0:
n+=1
else:
len(i)
self.mycursor.execute(
"INSERT INTO {}(Sim, ID, Password, CreatedOn) VALUES(%s, %s, %s, %s)".format(self.table_name), (i[0],i[1],i[2],i[3]))
self.myDB.commit()
self.mycursor.execute(
"INSERT INTO {}(Sim, ID, Password, CreatedOn) VALUES(%s, %s, %s, %s)".format(self.table_name), (i[0],i[1],i[2],i[3]))
self.myDB.commit()
print("added to database successfully")
self.myDB.commit()
return True
Expand Down

0 comments on commit 9ba13bc

Please sign in to comment.